systemjs-plugin-babel
Advanced tools
Comparing version 0.0.8 to 0.0.9
{ | ||
"name": "systemjs-plugin-babel", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"registry": "npm", | ||
@@ -9,4 +9,5 @@ "jspmPackage": true, | ||
"systemjs-babel-build": { | ||
"node": "./systemjs-babel-node.js", | ||
"browser": "./systemjs-babel-browser.js", | ||
"node": "./systemjs-babel-node.js" | ||
"default": "./systemjs-babel-browser.js" | ||
} | ||
@@ -13,0 +14,0 @@ }, |
@@ -7,4 +7,5 @@ var babel = require('systemjs-babel-build').babel; | ||
var modulesRegister = require('systemjs-babel-build').modulesRegister; | ||
var stage3 = require('systemjs-babel-build').presetStage3; | ||
var stage2 = require('systemjs-babel-build').presetStage2; | ||
var stage3 = require('systemjs-babel-build').pluginsStage3; | ||
var stage2 = require('systemjs-babel-build').pluginsStage2; | ||
var stage1 = require('systemjs-babel-build').pluginsStage1; | ||
@@ -46,2 +47,3 @@ var externalHelpers = require('systemjs-babel-build').externalHelpers; | ||
* stage2: true / false (defaults to true) | ||
* stage1: true / false (defaults to false) | ||
* plugins: array of custom plugins (objects or module name strings) | ||
@@ -57,3 +59,4 @@ * presets: array of custom presets (objects or module name strings) | ||
stage3: true, | ||
stage2: true | ||
stage2: true, | ||
stage1: false | ||
}; | ||
@@ -92,3 +95,3 @@ | ||
pluginAndPresetModuleLoads.push(pluginLoader['import'](plugin, module.id)); | ||
else if (plugin instanceof Array && typeof plugin[0] == 'string') | ||
else if (Array.isArray(plugin) && typeof plugin[0] == 'string') | ||
pluginAndPresetModuleLoads.push(pluginLoader['import'](plugin[0], module.id)); | ||
@@ -104,8 +107,2 @@ }); | ||
if (babelOptions.stage3) | ||
presets.push(stage3); | ||
if (babelOptions.stage2) | ||
presets.push(stage2); | ||
if (babelOptions.modularRuntime) { | ||
@@ -129,2 +126,17 @@ if (load.metadata.format == 'cjs') | ||
if (babelOptions.stage3) | ||
presets.push({ | ||
plugins: stage3 | ||
}); | ||
if (babelOptions.stage2) | ||
presets.push({ | ||
plugins: stage2 | ||
}); | ||
if (babelOptions.stage1) | ||
presets.push({ | ||
plugins: stage1 | ||
}); | ||
if (babelOptions.presets) | ||
@@ -142,3 +154,3 @@ babelOptions.presets.forEach(function(preset) { | ||
plugins.push(pluginAndPresetModules[curPluginOrPresetModule++]); | ||
else if (plugin instanceof Array && typeof plugin[0] == 'string') | ||
else if (Array.isArray(plugin) && typeof plugin[0] == 'string') | ||
plugins.push([pluginAndPresetModules[curPluginOrPresetModule++], plugin[1]]); | ||
@@ -145,0 +157,0 @@ else |
@@ -38,2 +38,38 @@ SystemJS Babel Plugin | ||
### ES Features | ||
This repo comes with its own Babel build which includes all ES6 and Stage 2 and Stage 3 features by default, except for the ES6 library polyfills. | ||
If ES6 polyfills are desired it is advisable to import core-js libraries manually as needed. | ||
To use Stage 1 features, these need to be manually enabled via configuration: | ||
```javascript | ||
SystemJS.config({ | ||
meta: { | ||
'*.js': { | ||
babelOptions: { | ||
stage1: true | ||
} | ||
} | ||
} | ||
}); | ||
``` | ||
If running in NodeJS or browsers that have ES2015 support, ES2015 feature transpilation can be disabled similarly: | ||
```javascript | ||
SystemJS.config({ | ||
meta: { | ||
'*.js': { | ||
babelOptions: { | ||
es2015: false | ||
} | ||
} | ||
} | ||
}); | ||
``` | ||
This allows workflows that just support ES modules and stage proposal transforms. | ||
### Building and Bundling | ||
@@ -58,9 +94,2 @@ | ||
## ES Features | ||
This repo comes with its own Babel build which includes all ES6 and Stage 3 features, except for the ES6 library polyfills. | ||
If ES6 polyfills are desired it is advisable to import core-js libraries manually as needed. | ||
### Custom Presets and Transforms | ||
@@ -76,5 +105,9 @@ | ||
}, | ||
babelOptions: { | ||
presets: ['custom-preset'], | ||
plugins: ['custom-plugin'] | ||
meta: { | ||
'*.js': { | ||
babelOptions: { | ||
presets: ['custom-preset'], | ||
plugins: ['custom-plugin'] | ||
} | ||
} | ||
} | ||
@@ -84,14 +117,18 @@ }); | ||
This way JSX support or other features can be included as needed. | ||
This way JSX support or other features can be included as needed (eg see http://jspm.io/0.17-beta-guide/installing-the-jsx-babel-plugin.html for jspm jsx support) | ||
You can pass options to Babel plugins the same way as in Node, without creating custom presets. | ||
You can also pass options to Babel plugins the same way as in Node, without creating custom presets. | ||
```javascript | ||
SystemJS.config({ | ||
babelOptions: { | ||
plugins: [ | ||
[ "react-transform", { | ||
"transforms": [{"transform": "react-transform-jspm-hmr"}] | ||
}] | ||
] | ||
meta: { | ||
'*.js': { | ||
babelOptions: { | ||
plugins: [ | ||
[ "react-transform", { | ||
"transforms": [{"transform": "react-transform-jspm-hmr"}] | ||
}] | ||
] | ||
} | ||
} | ||
} | ||
@@ -98,0 +135,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138
2138426
42857