You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: deprecate default export in favor of named export (#641)
This deprecates the default export in favor of the new named export `sveltePreprocess`. It's done to ensure a better interop between CJS and ESM without resorting to hacks in the future. It also enables people using `"module": "NodeNext"` in their `tsconfig.json` to import without type errors.
The sub exports were also adjusted so that the transpiled TS output doesn't include `__importDefault` wrappers, which makes Node's static analysis miss those named exports.
Related: #591
Copy file name to clipboardExpand all lines: README.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -41,10 +41,10 @@ Writing your own preprocessor for, i.e SCSS is easy enough, but it can be cumber
41
41
It is recommended to use with `svelte.config.js` file, located at the project root. For other usage, please refer to [usage documentation](#usage-documentation).
Copy file name to clipboardExpand all lines: docs/migration-guide.md
+6
Original file line number
Diff line number
Diff line change
@@ -97,3 +97,9 @@ In `v4`, your TypeScript code will only be transpiled into JavaScript, with no t
97
97
- Node 18 or higher is required now
98
98
- When using TypeScript, the minimum required version is now 5.0, `"verbatimModuleSyntax": true` is now required in your `tsconfig.json`, and the mixed imports transpiler (`handleMixedImports`) was removed
99
99
- The `preserve` option was removed as it's obsolete
100
+
- The default export is deprecated in favor of its new named export:
101
+
102
+
```diff
103
+
- import sveltePreprocess from 'svelte-preprocess';
104
+
+ import { sveltePreprocess } from 'svelte-preprocess';
// also export auto preprocessor as named export to sidestep default export type issues with "module": "NodeNext" in tsconfig.
10
+
// Don't just do export { sveltePreprocess } because the transpiled output is wrong then.
11
+
export{sveltePreprocess}from'./autoProcess';
12
+
13
+
// stand-alone processors to be included manually, use their named exports for better transpilation or else node will not detect the named exports properly
// both for backwards compat with old svelte-preprocess versions
31
+
// (was only default export once, now is named export because of transpilation causing node not to detect the named exports of 'svelte-preprocess' otherwise)
// both for backwards compat with old svelte-preprocess versions
41
+
// (was only default export once, now is named export because of transpilation causing node not to detect the named exports of 'svelte-preprocess' otherwise)
// both for backwards compat with old svelte-preprocess versions
18
+
// (was only default export once, now is named export because of transpilation causing node not to detect the named exports of 'svelte-preprocess' otherwise)
// both for backwards compat with old svelte-preprocess versions
34
+
// (was only default export once, now is named export because of transpilation causing node not to detect the named exports of 'svelte-preprocess' otherwise)
// both for backwards compat with old svelte-preprocess versions
23
+
// (was only default export once, now is named export because of transpilation causing node not to detect the named exports of 'svelte-preprocess' otherwise)
// both for backwards compat with old svelte-preprocess versions
12
+
// (was only default export once, now is named export because of transpilation causing node not to detect the named exports of 'svelte-preprocess' otherwise)
// both for backwards compat with old svelte-preprocess versions
42
+
// (was only default export once, now is named export because of transpilation causing node not to detect the named exports of 'svelte-preprocess' otherwise)
0 commit comments