Created
February 28, 2018 16:25
-
-
Save simon04/ea3fc9fc757e69d22297b941adb2fa6f to your computer and use it in GitHub Desktop.
Minimal buble-loader supporting webpack 4
This file contains 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
/* eslint-env node */ | |
const buble = require('buble'); | |
const loaderUtils = require('loader-utils'); | |
const path = require('path'); | |
module.exports = function BubleLoader(source) { | |
this.cacheable && this.cacheable(); | |
const options = Object.assign({transforms: {modules: false}}, loaderUtils.getOptions(this)); | |
const transformed = buble.transform(source, options); | |
transformed.map.file = this.resourcePath; | |
transformed.map.sources[0] = path.relative(process.cwd(), this.resourcePath); | |
transformed.map.sourceRoot = process.cwd(); | |
this.callback(null, transformed.code, transformed.map); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment