-
Notifications
You must be signed in to change notification settings - Fork 355
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
Provide ESM export for @patternfly/react-styles css components. #7054
Comments
Hi @smurrayatwork, are you trying to import from the |
In this case, indirectly. I was actually able to get this working by modifying the
The .mjs files are picked up by bundlers that recognize that extension as es modules. I haven't made a PR just yet but I will soon. |
+1 here Will got following error
|
I think the better way is add another code snippets for esm only const writeESMExport = (file, classMap) =>
outputFileSync(
join(outDir, file.replace(/.css$/, '.mjs')),
`
import('./${basename(file, '.css.js')}');
export default ${JSON.stringify(classMap, null, 2)};
`.trim()
); writeCJSExport(outPath, classMap);
writeDTSExport(outPath, classMap);
writeESMExport(outPath, classMap); |
Verified with https://www.npmjs.com/package/@patternfly/react-core/v/4.202.25 @patternfly/react-core is working fine with Vite now There has a esbuild bug in 4 hours ago evanw/esbuild#2177 Please make sure you are using |
Using bundlers that support ES Modules (such as vite) require ES Module exports. Currently, all of the component .js files under @patternfly/react-styles/css/components use
require
on .css files. It would be better to include in addition to this another file that usesimport
instead.A nice to have in addition to this es module file would be placing the
@patternfly/react-styles/css
directory under both@patternfly/react-styles/dist/esm
and@patternfly/react-styles/dist/js
. This would allow for bundlers to easily determine which .js files to use for ES modules and commonjs modules.The text was updated successfully, but these errors were encountered: