styleInject breaks tree-shaking
See original GitHub issueThis function doesn’t have a /*#__PURE__*/
prefix, which breaks tree-shaking. Moreover, when I try to prepend it myself through inject
option it gets stripped along with the entire string from the final bundle, which leaves you without CSS.
function inject(cssVariableName) {
return (
'\n' +
`/*#__PURE__*/ (${styleInjectFork})(${cssVariableName}${
Object.keys(styleInjectOptions).length > 0
? `,${JSON.stringify(styleInjectOptions, function(_key, value) {
if (typeof value === 'function') {
return value.toString();
}
return value;
})}`
: ''
});`
);
}
In my case, I forked styleInject
, because it’s missing some features, so I had to compose it slightly different into the string (wrap it with brackets to turn it into expression, which is then invokable).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Tree Shaking - webpack
Tree Shaking. Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of...
Read more >rollup-plugin-postcss - Bountysource
Extracting CSS into a single file breaks treeshaking. I only want to ship critical styles. So as rollup turns every entry point to...
Read more >Why you should build a React Component Library, and style it ...
Extracting CSS into a single file breaks treeshaking. We only want to ship critical styles. This wouldn't be ideal. We could do better....
Read more >vis-timeline - UNPKG
node_modules/style-inject/dist/style-inject.es.js","../. ... (match[2] || ' ') + isoTimes[i][0];\n break;\n }\n }\n if (timeFormat == null) {\n config.
Read more >Dependencies | umi_cps | npm - Open Source Insights
arrow_right antd. 3.26.16 Notes Relation Licenses Depende...
Version 3.26.16 Published April 26, 2020 Description
arrow_right father. 2.30.23 Notes Relation Licenses Depende...
Version 2.30.23 Published September 15,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, no. I was busy with other stuff. I intend to come back to this though, because I really need to solve this issue.
Thank you so much for that! I created a pull request, let’s hope they merge it.