Created
January 20, 2015 02:12
-
-
Save loganfsmyth/6f8520c7c96f61f0a5b8 to your computer and use it in GitHub Desktop.
Webpack 'use-strict' loader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var OriginalSource = require('webpack/lib/OriginalSource'); | |
module.exports = function(source, map){ | |
var identifier = this._module.identifier(); | |
this.cacheable(); | |
var origMap = this.sourceMap ? new OriginalSource(source, identifier, map) : null; | |
var strictPrefix = '"use strict";\n'; | |
source = strictPrefix + source; | |
if (origMap) origMap.node().prepend(strictPrefix); | |
return this.callback(null, source, origMap ? origMap.map() : null); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lovely!
why is this not on npm yet? ;)