Skip to content
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

Make CSS imports pure so that when imported for side effects, they aren't included in the resulting bundle #801

Open
lemonmade opened this issue Jul 31, 2024 · 1 comment

Comments

@lemonmade
Copy link
Owner

No description provided.

@lemonmade
Copy link
Owner Author

Looked at this. The rollup main part of the rollup plugin is

return {
code: exports
? `export default JSON.parse(${JSON.stringify(
JSON.stringify(exports),
)})`
: `export default undefined;`,
map: {mappings: ''},
moduleSideEffects: 'no-treeshake',
};
, and with changes to the following, CSS imported by the browser entry is correctly handled:

      return {
        code: exports
          ? `const module = /* #__PURE__ */ JSON.parse(${JSON.stringify(
              JSON.stringify(exports),
            )});\nexport default module;`
          : `export default undefined;`,
        map: {mappings: ''},
        // moduleSideEffects: 'no-treeshake',
      };

However, CSS outside the browser entry point is not preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant