Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 code is not bundle safe #1

Open
coryshaw opened this issue Apr 19, 2018 · 8 comments
Open

ES6 code is not bundle safe #1

coryshaw opened this issue Apr 19, 2018 · 8 comments

Comments

@coryshaw
Copy link

Hello, This is a nice little utility! We noticed that it uses let and const (ES6) and is breaking our webpack build due to the fact that Uglify JS cannot minify ES6 code. Super easy to fork into our own function but just wanted to give a heads up. Thanks!

@mvayngrib
Copy link
Owner

@coryshaw as you're already using webpack, you can just configure it to transpile this module to es5. Use babel-loader and limit it to transpiling only this module either with include or test (test: /node_modules\/parse-usdl\/.*?\.js$/)

nathany added a commit to RobotsAndPencils/parse-usdl that referenced this issue Aug 20, 2018
@nathany
Copy link

nathany commented Aug 20, 2018

@mvayngrib I had some trouble getting the transpile to work. Should the parse-usdl library do the transpiling itself?

@nathany
Copy link

nathany commented Sep 1, 2018

I'm not sure what it takes to get the library to transpile and work with projects that may not even use babel. For such a small library, my current solution for IE11 support is to remove the ES6 (from a fork).

@mvayngrib
Copy link
Owner

@nathany the problem with transpilation in-library is we don't know who our users are. IE11 users will want it transpiled a different way from people using chrome. I think it's better to delegate this decision to the consumer of this library, who will use some combination of webpack and babel-preset-env to create the bundle that works in their particular environment.

@nathany
Copy link

nathany commented Sep 4, 2018

I'm not sure if there is a precedent from other libraries, but this is my first time running into this issue.

If the transpiled code isn't included, perhaps the solution is to provide better documentation in the README. As of yet, I haven't been able to get the transpiling working so that this library works in Internet Explorer 11 (yes, I know, why do we need to support IE 11 anyway, but we do).

@mvayngrib
Copy link
Owner

mvayngrib commented Sep 4, 2018

@nathany maybe I can help. What are you using to transpile the rest of your code? Babel with babel-preset-env + webpack is the standard these days, and they support transpiling per browser (including ie 11). Take a look at https://babeljs.io/docs/en/next/babel-preset-env.html

@mvayngrib
Copy link
Owner

mvayngrib commented Sep 4, 2018

i made a small example for you: https://github.com/mvayngrib/usdl-example

run: npm run build
open index.html (it will log a parsed usdl license to the console)
fiddle around with browser support in babel.config.js to see the differently transpiled code

edit: poking around, i see that usdl-example is not set up the ideal way. Webpack can invoke babel directly, see babel-loader

@nathany
Copy link

nathany commented Sep 4, 2018

Okay. Will have to get back to you on this. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants