Skip to content

Instantly share code, notes, and snippets.

@loganfsmyth
Created January 20, 2015 02:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loganfsmyth/6f8520c7c96f61f0a5b8 to your computer and use it in GitHub Desktop.
Save loganfsmyth/6f8520c7c96f61f0a5b8 to your computer and use it in GitHub Desktop.
Webpack 'use-strict' loader
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);
};
@danielberndt
Copy link

Lovely!
why is this not on npm yet? ;)

@mistadikay
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment