Zod- / jsVideoUrlParser

A javascript parser to extract informations like provider, channel, id, start time from YouTube, Vimeo, Dailymotion, Twitch,... urls
MIT License
234 stars 73 forks source link

UglifyJS error during webpack traspilation #43

Closed thsmrtone1 closed 5 years ago

thsmrtone1 commented 6 years ago

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:

ERROR  Failed to compile with 1 errors

notification.js from UglifyJs
Name expected [notification.js:400,6]

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.

alec-brooks commented 6 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.

Zod- commented 6 years ago

@thsmrtone1 Use a more recent uglifier that supports ES6. From this issue you can use uglifyjs-webpack-plugin or uglify-js@3 directly.

Fi1osof commented 6 years ago

Using dist-version solve it for me import urlParser from "js-video-url-parser/dist/jsVideoUrlParser.js"; Using with react-scripts.