Closed TylorS closed 8 years ago
I ran into this today as well, using Webpack's production build settings (which use uglify).
To solve it for now, I told Webpack to run snabbdom-to-html
through Babel.
It feels so counter-productive to do this for the client-side bundle, since uglify is going to delete the code again anyway...
@SkaterDad FWIW I'm using the global
flag for babel. https://github.com/TylorS/cycle-snabbdom/blob/master/package.json#L11
Oops. I apologize. Thats a babelify only option.
Here's the part of my webpack config file which handles .js files. Typically I just exclude the entire node_modules folder, but put in this weird regex for now.
I only do this in the client-side bundle's "production" build setup, since it's the only one I'm minimizing.
loaders: [
{
test: /\.js$/,
loaders: ['babel?cacheDirectory=true&presets=es2015'],
exclude: /node_modules.((?!snabbdom-to-html)).*/ //webpack pulls in snabbdom-to-html as part of cycle-snabbdom. Uflify doesn't like es6 code.
//exclude: /node_modules/
}
]
Hey there, sorry for the late reply. @TylorS @SkaterDad (for some reason I'm not getting any emails from GitHub)
I understand the problem but I'm no sure how we should fix this. This library is targeting node v4 and up where inline templates and arrow functions work ok.
Would it help having a transpiled (to ES5) version of the library meant for browser use?
@acstll I think including a transpiled version for browsers would solve this. I assume the bundlers are smart enough to handle that.
This could allow some cool things like a site which shows live previews of the conversion.
This could allow some cool things like a site which shows live previews of the conversion.
That's a really nice idea. :+1:
I know Browserify takes into account the browser
key on package.json, I have no idea about Webpack, I'll do some research.
This is the plan then
browser
in package.json to target that buildbrowser
keySeems like a solid plan :+1:
I plan to cut a release with this and #7 (plus thunks
) this afternoon, I wanted to do this earlier but I haven't been able to… :sweat: :blush:
I recently made an update to cycle-snabbdom and I added support for server-side rendering there with this library, of course.
I decided that I would like to create
dist/
builds for users to include in<script>
tags, which goes through well enough for browserify + babelify. However when trying to minimize the generated file with uglifiy-js (latest version) this line here throws a parsing error regarding the backticks, because files in yournode_modules
are not also passed through browserify+babelify in the same fashion.