Closed thsmrtone1 closed 5 years ago
I am experiencing this issue as well, I am using webpack 3.8.1, though the build on my application is being managed by react-scripts 1.1.4.
Manually adding the "module"
field to the package.json for jsVideoUrlParser, as suggested, fixed the issue for me. It would be good to see this added.
@thsmrtone1 Use a more recent uglifier that supports ES6. From this issue you can use uglifyjs-webpack-plugin or uglify-js@3 directly.
Using dist-version solve it for me import urlParser from "js-video-url-parser/dist/jsVideoUrlParser.js"; Using with react-scripts.
First thing's first, I am not a javascript pro, nor am I a webpack wizard, so bear with me while I try to convey my issue.
When running
webpack -p
for my project, I'm getting an error:After some research it appears this is due to webpack trying to run the ES6 code from js-video-url-parser's 'lib' directory through UglifyJS. So my workaround to get this package to work is to add 'js-video-url-parser' to the list of excludes in webpack.config.js.
Upon even more research, it appears that the 'js-video-url-parser' will transpile/uglify as designed if webpack uses the pre-transpiled version located in the 'dist' directory, but webpack will not use this version unless the 'modules' field in package.json is set to 'dist/jsVideoUrlParser.js'.
So I guess my proposal is to add a field in package.json
"module": "dist/jsVideoUrlParser.js"
.If anyone else has any further input to this issue please tell me I'm not crazy.