Description
I upgrade the Google Traceur to the latest 0.0.110. However, the compilation-output ES5 JavaScript program can't work in the web browser.
- The transpiling command for Traceur:
node_modules/.bin/traceur
--script=www/js/widget-nest-thermostat.bbjs
--out=www/js/widget-nest-thermostat.js
--require=true
--arrow-functions=true --block-binding=true --classes=true
--computed-property-names=true --default-parameters=true
--destructuring=true --for-of=true --generators=true --numeric-literals=true
--property-methods=true --property-name-shorthand=true --rest-parameters=true
--spread=true --symbols=true --template-literals=true --unicode-escape-sequences=true
--unicode-expressions=true --proper-tail-calls=true --annotations=true
--array-comprehension=true --async-functions=true --async-generators=true
--exponentiation=true --export-from-extended=true --for-on=true
--generator-comprehension=true --member-variables=true --spread-properties=true
--types=true --experimental --source-maps=file
- The traceur runtime has been introduced in the HTML page.
The file "traceur-runtime.js" is copied from the folder "node_modules/traceur/bin".
- The Error is thrown from the web browser, when I visit the web page.
**TypeError: Cannot read property 'default' of undefined**
By scanning the compilatio-output ES5 JS program, I discovered the error point is
var $__initTailRecursiveFunction = $traceurRuntime.getModule($traceurRuntime.normalizeModuleName("traceur/dist/commonjs/runtime/modules/initTailRecursiveFunction.js", "widget-nest-thermostat.bbjs")).default;
That's to say, $traceurRuntime.getModule($traceurRuntime.normalizeModuleName("traceur/dist/commonjs/runtime/modules/initTailRecursiveFunction.js", "widget-nest-thermostat.bbjs")) returns null.
Memo: in my project, ES6 JS file is suffixed with ".bbjs". After they are compiled, their corresponding ES5 file is ".js".