-
Notifications
You must be signed in to change notification settings - Fork 122
transpiling with babel does not work #127
Comments
Transpiling is only run against ES6 modules. Because you aren't using any ES6 module syntax, the source isn't being detected as ES6 automatically. Either add some ES6 syntax (eg |
Sort of makes sense. I added var React = {};
function Foo (x) {
if (0) { return (z) => { return z + x; }; }
return ( <div>{x}</div>);
}
export { Foo }; Now it gives different error message:
What is wrong now? |
By default jspm disables jsx support as it is not an ES6 feature. You can override the config and set |
Good, now my build.js is: var Builder = require('systemjs-builder');
var builder = new Builder({
babelOptions: { blacklist: [] },
baseURL: '.',
transpiler: 'babel',
});
builder.buildSFX('code', 'result.js')
.then(function () { console.log("Ok"); })
.catch(function (err) { console.log("ERROR: "+err); }); Got next error:
I fixed that by editing compilers/es6.js directly, then got another error:
Seems it's problem in Babel 5.0, the build.js works when run with Babel 4.7. |
there is problem with Babel 4.7.16 too, module paths are wrong: build.js: var Builder = require('systemjs-builder');
var builder = new Builder({
transpiler: 'babel',
babelOptions: { blacklist: [] },
baseURL: 'lib',
map: { 'pages': '../js/pages' }
});
builder.buildSFX('pages/main', 'result.js')
.then(function () { console.log("Ok"); })
.catch(function (err) { console.log("ERROR: "+err); }); lib/common.js: var COMMON = {};
export default COMMON; js/pages/main.js: import _ from 'common';
console.log("Running OK"); Building works, but running fails:
Problem seems to be that although main module path is correct, modules are registered with filesystem paths for some reason (with ../js/ in front). [ Background: I'm trying to convert working 6to5/sysjs-builder v0.8 setup to Babel + sysjs-builder v0.10 ] |
The bundle itself doesn't work in Node, it's for the browser. If you're looking for Node execution there's no need to use a build in Node. |
The problem is i get same message in browser... |
If you're looking to get support on the project it is advisable to ask in the Gitter room and not in the issue queue. That said in this scenario, sfx bundles will run with just that single script tag present. If there is a bug please provide the exact details of what you are including in the browser and the message you are getting. |
Using the files mentioned in previous message, I added html page: <!DOCTYPE html><html><body><p>Test</p>
<script src="result.js"></script>
</body></html> When opening it in browser, following line appears:
For correct operation I would expect that the I think you should have enough info to reproduce the bug on your own. |
Thanks - this was actually a bug which I've fixed in the above commit. I'm working on providing a new release shortly. In the mean time the work around here would be to run: builder.buildSFX('../js/pages', 'result.js') |
Thank you, I'll wait for next release. |
package.json
code.js
build.js
node build.js
gives following output:which basically means it did not load Babel.
I don't know if it's an issue with SystemJS-builder itself or just the examples in README
need to be updated.
The text was updated successfully, but these errors were encountered: