-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: deprecate default export in favor of named export #641
Conversation
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.
|
||
// both for backwards compat with old svelte-preprocess versions | ||
// (was only default export once, now is named export because of transpilation causing node not to detect the named exports of 'svelte-preprocess' otherwise) | ||
export default babel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need the default export here? IIRC these were re-exported with names in the package entrypoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing this out of fear that someone may have done import babel from 'svelte-preprocess/.../babel'
. We should definitely remove it in the next major
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find that a tad unlikely, but that's an unfortunately good point 🥲
update documentation example to correctly use changes from PR sveltejs#641
update documentation example to correctly use changes from PR #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 theirtsconfig.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 (comment)
Before submitting the PR, please make sure you do the following
pnpm lint
!)Tests
npm test
orpnpm test