Generate plugin list file - #4725
Conversation
Removes the importing of all plugins in src/util/resolveConfig to avoid importing CSS. Import the built plugin list file instead.
| import * as corePlugins from '../src/plugins' | ||
| import fs from 'fs' | ||
| import path from 'path' | ||
|
|
||
| const corePluginList = Object.keys(corePlugins) | ||
|
|
||
| fs.writeFileSync( | ||
| path.join(__dirname, '..', 'src', 'corePluginList.js'), | ||
| `export default ${JSON.stringify(corePluginList)}` | ||
| ) |
There was a problem hiding this comment.
Q: Since this logic is only used by resolveConfig.js can we not generate the file and directly move this to resolveConfig.js?
There was a problem hiding this comment.
This would make it so we would have to commit a generated file to the repo. It would also have to conform to the linter. Is this desired behavior?
There was a problem hiding this comment.
I meant something more similar to the older logic.
There was a problem hiding this comment.
I'm confused as to what this means. We cannot do this in resolveConfig.js because it would mean a package consumer would have to import all the plugins and thus import CSS from the preflight plugin. See linked issue for why this is a problem.
There was a problem hiding this comment.
Since exports are transpiled to commonjs, there may exist some trick to get a list of all of them. Just suppositions though.
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
|
Thanks, I'll publish a new release with this fix today 👍🏻 Long-term though it's still way better to not have this stuff in your client-side bundle at all. You can look at the tailwindcss.com repo if you want to see how we do this ourselves with preval. resolveConfig carries with it some really big dependencies you don't want to ship to the client. |
|
This actually prevents npm or yarn from installing on my system: Edit: Using Node v12. Same result with Node V14: |
|
Breaks mine too. Quick fix would be to remove the install script. @adamwathan. Strange because I actually created a discussion over at the NPM repository and was told to use this. |
Removes the importing of all plugins in
src/util/resolveConfigto avoid importing CSS.Import the built plugin list file instead.
resolves #4681