From e786b5b7bf7460da9af9f5d543bb70ddcb2951b2 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Wed, 30 Dec 2015 15:40:19 +0300 Subject: [PATCH] Make transformers more straightforward --- src/utils/transformBundle.js | 2 +- test/form/transform-bundle-plugin/_config.js | 6 +++--- test/sourcemaps/transform-bundle/_config.js | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/utils/transformBundle.js b/src/utils/transformBundle.js index 2bebeea..efbe3a1 100644 --- a/src/utils/transformBundle.js +++ b/src/utils/transformBundle.js @@ -9,7 +9,7 @@ export default function transformBundle ( source, transformers ) { } return transformers.reduce( ( previous, transformer ) => { - let result = transformer( previous ); + let result = transformer( previous.code, previous.map ); if ( result == null ) return previous; diff --git a/test/form/transform-bundle-plugin/_config.js b/test/form/transform-bundle-plugin/_config.js index 36a30ab..6b54ad3 100644 --- a/test/form/transform-bundle-plugin/_config.js +++ b/test/form/transform-bundle-plugin/_config.js @@ -3,13 +3,13 @@ module.exports = { options: { plugins: [ { - transformBundle: function (result) { + transformBundle: function (code) { return '/* first plugin */'; } }, { - transformBundle: function (result) { - return result.code + '\n/* second plugin */'; + transformBundle: function (code) { + return code + '\n/* second plugin */'; } } ] diff --git a/test/sourcemaps/transform-bundle/_config.js b/test/sourcemaps/transform-bundle/_config.js index f83ae5f..abb986d 100644 --- a/test/sourcemaps/transform-bundle/_config.js +++ b/test/sourcemaps/transform-bundle/_config.js @@ -9,17 +9,17 @@ module.exports = { options: { plugins: [ { - transformBundle: function ( source ) { + transformBundle: function ( code, map ) { var options = { fromString: true }; - if ( source.map != null ) { - options.inSourceMap = source.map; + if ( map != null ) { + options.inSourceMap = map; options.outSourceMap = "out"; } - var result = uglify.minify( source.code, options ); + var result = uglify.minify( code, options ); - if (source.map != null) { + if ( map != null ) { result.code = result.code.slice( 0, -25 ); }