Browse Source

Make transformers more straightforward

gh-438-b
Bogdan Chadkin 9 years ago
parent
commit
e786b5b7bf
  1. 2
      src/utils/transformBundle.js
  2. 6
      test/form/transform-bundle-plugin/_config.js
  3. 10
      test/sourcemaps/transform-bundle/_config.js

2
src/utils/transformBundle.js

@ -9,7 +9,7 @@ export default function transformBundle ( source, transformers ) {
} }
return transformers.reduce( ( previous, transformer ) => { return transformers.reduce( ( previous, transformer ) => {
let result = transformer( previous ); let result = transformer( previous.code, previous.map );
if ( result == null ) return previous; if ( result == null ) return previous;

6
test/form/transform-bundle-plugin/_config.js

@ -3,13 +3,13 @@ module.exports = {
options: { options: {
plugins: [ plugins: [
{ {
transformBundle: function (result) { transformBundle: function (code) {
return '/* first plugin */'; return '/* first plugin */';
} }
}, },
{ {
transformBundle: function (result) { transformBundle: function (code) {
return result.code + '\n/* second plugin */'; return code + '\n/* second plugin */';
} }
} }
] ]

10
test/sourcemaps/transform-bundle/_config.js

@ -9,17 +9,17 @@ module.exports = {
options: { options: {
plugins: [ plugins: [
{ {
transformBundle: function ( source ) { transformBundle: function ( code, map ) {
var options = { fromString: true }; var options = { fromString: true };
if ( source.map != null ) { if ( map != null ) {
options.inSourceMap = source.map; options.inSourceMap = map;
options.outSourceMap = "out"; 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 ); result.code = result.code.slice( 0, -25 );
} }

Loading…
Cancel
Save