thecreation/breakpoints-js

Error when minifying this package with Webpack

Closed this issue · 5 comments

Checklist

  • I'm using version [1.0.5]

Description

Upgrade to the recent release of breakpoints and it is causing an error when attempting to minify using webpack.

Error Output:

/js/app.js from UglifyJs
Unexpected token: name (continues) [./node_modules/breakpoints-js/dist/breakpoints.es.js:35,0][/js/app.js:51806,8]

Looking at the recent update I would probably suspect the comments in your json file to be the culprit. amazingSurge@6c89459#diff-df39304d828831c44a2b9f38cd45289c Json does not support comments and this is going to break most minify type packages. But that's only a guess.

Hi,
In this version, i expose es module by using "module" key in package.json. Will this causing the issue? Did you using rollup or babel with webpack?
And it may using uglify-es instead of uglify-js https://www.npmjs.com/package/uglify-es-webpack-plugin?

Regards,
JimbaCheng

Thanks for the help. I am using laravel mix to manage my front end dependencies and I think mix uses uglify-js internally. I will look for a way to switch to uglify-es and see if that helps.

For using laravel mix, you can see
https://github.com/JeffreyWay/laravel-mix/blob/master/docs/quick-webpack-configuration.md

Add custom field to webpack configuration,

mainFields: ['main'],

Or you can using mix.babel()

adding the mainFields to my mix config does allow the package to build and minifiy. It all appears to be working again. Thanks.

mix.webpackConfig({
    resolve: {
        mainFields: ['main'],
    }
});