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

Add support for Webpack 2's tree-shaking #926

Merged
merged 6 commits into from
Jan 31, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/build/babel/preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const babelRuntimePath = require.resolve('babel-runtime/package')

module.exports = {
presets: [
require.resolve('babel-preset-es2015'),
[require.resolve('babel-preset-es2015'), { modules: false }],
require.resolve('babel-preset-react')
],
plugins: [
Expand Down
12 changes: 10 additions & 2 deletions server/build/loaders/emit-file-loader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import loaderUtils from 'loader-utils'
import { transform } from 'babel-core'

module.exports = function (content, sourceMap) {
this.cacheable()
Expand All @@ -10,7 +11,14 @@ module.exports = function (content, sourceMap) {
const opts = { context, content, regExp }
const interpolatedName = loaderUtils.interpolateName(this, name, opts)

this.emitFile(interpolatedName, content, sourceMap)
const transpiled = transform(content, {
presets: [
'es2015'
],
sourceMaps: 'both',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd like to disable sourceMaps on production

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

inputSourceMap: sourceMap
})
Copy link
Contributor

@nkzawa nkzawa Jan 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's cool if this transformation can be done as an option of this loader, maybe by passing a function for changing content and sourceMap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! That'd be great.


this.callback(null, content, sourceMap)
this.emitFile(interpolatedName, transpiled.code, transpiled.map)
this.callback(null, transpiled.code, transpiled.map)
}