-
Notifications
You must be signed in to change notification settings - Fork 293
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 Rollup/Vite generated exports #801
Fix Rollup/Vite generated exports #801
Conversation
🦋 Changeset detectedLatest commit: ae10b85 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…veloper.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag Vite/Rollup sets this property to 'Module' which confuses _.isPlainObject - https://rollupjs.org/guide/en/#outputgeneratedcode (output.generatedCode.symbols) - vitejs/vite#5018 - https://github.com/vitejs/vite/blob/757a92f1c7c4fa961ed963edd245df77382dfde6/packages/vite/src/node/build.ts#L466-L469
value, | ||
/(features_compositionOnly__1o6ek504|features_styleCompositionInSelector__1o6ek507|features_styleVariantsCompositionInSelector_variant__1o6ek50a)\s/g, | ||
); | ||
const exportsObject = evalCode(`module.exports = ${exports}`, 'dummy.js'); |
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.
Why are we using eval here? Looks like we could just snapshot exports
to the same effect?
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.
Yes, of course. I wanted to make it easier to read than
expect(exports).toMatchInlineSnapshot(
`"{compositionOnly:'features_mergedStyle__1o6ek500 features_styleWithComposition__1o6ek501',mergedStyle:'features_mergedStyle__1o6ek500',styleCompositionInSelector:'features__1o6ek505 features__1o6ek506',styleVariantsCompositionInSelector:{variant:'features__1o6ek508 features__1o6ek509'},styleVariantsWithComposition:{variant:'features_styleVariantsWithComposition_variant__1o6ek502 features_mergedStyle__1o6ek500'},styleVariantsWithMappedComposition:{variant:'features_styleVariantsWithMappedComposition_variant__1o6ek503 features_mergedStyle__1o6ek500'},styleWithComposition:'features_styleWithComposition__1o6ek501 features_mergedStyle__1o6ek500'}"`,
);
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.
Could we use JSON.parse instead?
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.
Nope, not a JSON string (keys are not quoted and values are quoted with single quotes)
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.
Looks good. Just a small tweak to the changeset.
Co-authored-by: mattcompiles <[email protected]>
generatedCode: 'es2015'
for rollup build vitejs/vite#5018