lemonmade / quilt

MIT License
39 stars 8 forks source link

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

Open lemonmade opened 2 months ago

lemonmade commented 1 month ago

Looked at this. The rollup main part of the rollup plugin is https://github.com/lemonmade/quilt/blob/f775fdfb1a5d3473dd6f8d2ea9c66f96aa77606c/packages/rollup/source/features/css.ts#L41-L49, 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.