Giter Club home page Giter Club logo

Comments (6)

kofrasa avatar kofrasa commented on July 18, 2024

Thanks for the report @ericfong

Can you please confirm if you get the same issues using the previous version 1.3.3.

I want to confirm that this is due to porting to es6 and not because of moving the index.js to the project root since the contents have barely changed.

from mingo.

kofrasa avatar kofrasa commented on July 18, 2024

There is tutorial here on how to use webpack with es6

http://ccoenraets.github.io/es6-tutorial/setup-webpack/

I think what needs to happen is that, you translate the files first with babel before passing it to uglify.

from mingo.

ericfong avatar ericfong commented on July 18, 2024

Thanks for your tutorial.

I confirm that
version 1.2.0 success
version 1.3.0 fail

I think the problem come from my webpack setting

  exclude: /(node_modules|bower_components)/,

I am expecting that npm modules will export an es5 friendly release. (I am not sure that is a norm or not)

If I remove the exclude setting, babel will re-compile all node_modules. And some node_modules' .babelrc depend on some plugins that not installed

So far, I need to either manually blacklist or whitelist node_modules to transpile (which is too much work).

Do a little study about that and found
https://github.com/rollup/rollup/wiki/pkg.module#wait-it-just-means-import-and-export--not-other-future-javascript-features

Seems rollup suggest that when publishing es6 code, means transpile all es6 to es5 except import export

Following babel-preset-env setting may help:

  "env": {
    "module": {
      "presets": [["env", { "targets": { "browsers": "> 1%" }, "useBuiltIns": true, "modules": false }]],
      "plugins": [...],
    },
    "main": {
      "presets": [["env", { "targets": { "uglify": true }, "useBuiltIns": true }]],
      "plugins": [...],
    },
  },

from mingo.

kofrasa avatar kofrasa commented on July 18, 2024

Sounds like you found a nice workaround. I use rollup for mingo and the distribution provides a compiled UMD-style version in dist/mingo.js.

The approach you described appears to be the simplest. Library authors should be vending the es5 compiled versions along with the es6 sources so excluding node_modules and setting modules: false should work fine. I assume that will load the file at the main entry point which is the es5 version. https://github.com/kofrasa/mingo/blob/master/package.json#L5

See the file node_modules/mingo/dist/mingo.js in your project environment.

from mingo.

ericfong avatar ericfong commented on July 18, 2024

I finally solved by installing webpack-babel-env-deps

which will include mingo into babel transpile process

Thanks

from mingo.

marbemac avatar marbemac commented on July 18, 2024

For those using webpack, you can just toss this into your setup, where config is your webpack configuration object. I'm using lodash here, but you get the idea!

_.set(
  config,
  'resolve.alias',
  _.merge({}, _.get(config, 'resolve.alias', {}), {
    mingo: 'mingo/dist/mingo.min.js',
  })
);

from mingo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.