-
Notifications
You must be signed in to change notification settings - Fork 186
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
usage with webpack as es module #451
Comments
@selul I see, that there is a problem with version module in dist. However, your issue is not related to it. Originally, import { createRequire } from 'module';
const require = createRequire(import.meta.url);
export const { version } = require('../package.json'); Webpack converts it into: const version_require = (0,external_module_namespaceObject.createRequire)("file:///<path>/node_modules/.pnpm/[email protected]/node_modules/csso/lib/version.js"); So |
Thanks a lot for the insights, from checking my webpack config I don't do anything in particular that could affect browser config. {
externals: {
"aws-sdk": "aws-sdk"
},
optimization: {
minimize: false,
},
externalsType: "node-commonjs",
mode: "production",
stats: "minimal",
target: "node14",
watch: false,
experiments: {
outputModule: true,
},
devtool: "inline-cheap-module-source-map",
output: {
module: true,
library: {
type: "module",
},
filename: "index.mjs",
path: resolve( "./dist/" ),
}
}; As for the "sideEffects": false,
"type": "module", |
Thank you for sharing your webpack config. I tried it with (latest versions):
And bundle seems to work (no exceptions). I suppose, the problem is connected with You also could try:
|
Thanks a lot for feedback, adding |
hi,
I'm trying to use csso library with webpack as es module. The entry file is:
and on the output file, I get
which throws an error since versions.js is not present in the final build.
Any idea what could be wrong? I see that version.js is not used in the internal library code but since this package.json is not using
sideEffects:false
the tree shaking mechanism will still include this in the final build.Also, I would like to mention that the version before 5.0 is working fine, so it might be something related to the dual build mechanism implemented in 5.0.
Any help is appreciated.
The text was updated successfully, but these errors were encountered: