Saturday, 15 May 2010

javascript - Experimenting with babeljs+amd getting undefined for module -


I'm experimenting with the requirementsJS with babel.js. The requirement is given, I can not leave it sad: (I know that in BALJS docs it has been found that there is a - module AMD clear flag that defines ASD code to ASD. I Quick Examples "Application" to check it Here's the structure:

  | - build.sh | - index.html | - JS | | - Property | | | - | asseta.es6 | | | - asseta.js | || | - | bootstrap.es6 | | `- bootstrap.js |` - Main.JS `- node_module  

Index.html

  & lt; body & gt; & lt; p & gt; Hello World! This is HTML5 boilerplate. & Lt; / p & gt; & lt; script type = "text / javascript" src = "node_modules / needjs / require.js" data-main = "js / main.js" & gt; Lt; / script & gt; & lt; / body & gt;  

main.js

  (function () (require.config ({baseUrl : "Js / assets"}; (["bootstrap"], function (bootstrap) {bootstrap.ready (function (sum) {console.log (sum (1,2,3));});}); } ());  

bootstrap.es6

  imported from the etta; Console.log (asseta); // Undefined: (Export to Export Function (CB) {cb (asseta.sum);}  

asseta.es6

  Export function sum (. .nums) {return nums.reduce (> (ACC, number) => ACC = =), 0);}  

My problem with the application is that Well, if I log out of it, then I found an existing object with the prepared function -> OK but bootstrap Module

what am I missing

additional information Mr.

/ H3>

build.sh script only 0.6 files ES5 .js

  #! / Bin / sh babel - Module amd js / property / bootstrap. AS 6-A JS / Asset / Bootstrap.JS Babel - Module AMD JS / Assets / Asset.AS 6-A JS / Asset / Etta.JS  

This was a user error. I did not forget to default keyword asseta.es6

export default function sum (... nums) { Return nums.reduce (((ACC, number) => ACC + = number), 0); }

Or to fix this, the second way would be to leave assets with the keyword default , but the refactor bootstrap as

  import {sum} from 'asseta';  

No comments:

Post a Comment