quilt icon indicating copy to clipboard operation
quilt copied to clipboard

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

Open lemonmade opened this issue 1 year ago • 1 comments

lemonmade avatar Jul 31 '24 04:07 lemonmade

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.

lemonmade avatar Aug 05 '24 21:08 lemonmade