mapbox / mapbox-sdk-js

A JavaScript client to Mapbox services, supporting Node, browsers, and React Native
Other
718 stars 186 forks source link

Unable to build bundle #380

Closed katydecorah closed 4 years ago

katydecorah commented 4 years ago

While attempting to release 0.11.0 #371, I receive the following error when attempting to build the bundle (npm run bundle):

created umd/mapbox-sdk.js in 620ms
Parse error at umd/mapbox-sdk.js:1478,6
      const list = errorMessages.map(function(message) {
      ^
ERROR: Unexpected token: keyword (const)
    at JS_Parse_Error.get (eval at <anonymous> (/Users/katydecorah/Documents/GitHub/mapbox/mapbox-sdk-js/node_modules/uglify-js/tools/node.js:20:1), <anonymous>:71:23)
    at fatal (/Users/katydecorah/Documents/GitHub/mapbox/mapbox-sdk-js/node_modules/uglify-js/bin/uglifyjs:291:53)
    at run (/Users/katydecorah/Documents/GitHub/mapbox/mapbox-sdk-js/node_modules/uglify-js/bin/uglifyjs:235:9)
    at Object.<anonymous> (/Users/katydecorah/Documents/GitHub/mapbox/mapbox-sdk-js/node_modules/uglify-js/bin/uglifyjs:160:5)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @mapbox/mapbox-sdk@0.11.0 bundle: `rollup --config ./rollup.config.js && uglifyjs umd/mapbox-sdk.js > umd/mapbox-sdk.min.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @mapbox/mapbox-sdk@0.11.0 bundle script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/katydecorah/.npm/_logs/2020-06-26T12_31_11_267Z-debug.log

I believe this const statement was introduced when @mapbox/fusspot was updated to the latest version.

@andrewharvey A couple options I'm thinking about so far, curious what you think:

  1. See if we can roll back @mapbox/fusspot
  2. Add babel to the the rollup.config.js to properly transform es6 features.
katydecorah commented 4 years ago

One more idea, we could replace uglifyjs with https://github.com/terser/terser, but this may risk limiting browser support to modern browsers https://caniuse.com/#feat=const

andrewharvey commented 4 years ago

Hey @katydecorah thanks for catching this!

I originally upgraded fusspot to use v.objectOf which was only introduced in one of the later releases https://github.com/mapbox/fusspot/blob/master/CHANGELOG.md, however I found it wasn't working as I liked expected and in the end swapped back to v.strictShape in https://github.com/mapbox/mapbox-sdk-js/pull/368/commits/d890ee4bff43ac816fa9a67bef4a5af6c54dad95

So we're not actually needing to use an upgraded fusspot, so I'm happy to just revert it back to 0.4.0 for now. That's the simplest solution right now.

Then we can look into other options like babel or terser in future work, hows that sound @katydecorah?

katydecorah commented 4 years ago

So we're not actually needing to use an upgraded fusspot, so I'm happy to just revert it back to 0.4.0 for now. That's the simplest solution right now.

@andrewharvey sounds great to me! And #381 is a great idea, too!

andrewharvey commented 4 years ago

@katydecorah I wasn't sure if you wanted to do this change or were looking for help, so I put together some PR's to address this. I think those can be merged if you're happy with them, and since they don't need to go in the CHANGELOG, after they are merged the 0.11.0 tag can be created and publish the release to npm.

katydecorah commented 4 years ago

I think those can be merged if you're happy with them, and since they don't need to go in the CHANGELOG, after they are merged the 0.11.0 tag can be created and publish the release to npm.

Thanks @andrewharvey. This is complete! v0.11.0 is published to npm.