-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Changes from 1 commit
685c005
ee6752b
8020f39
d93d6c6
8a6f34f
4cfae74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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() | ||
|
@@ -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', | ||
inputSourceMap: sourceMap | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
} |
There was a problem hiding this comment.
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 productionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.