Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

continuation.js missing from dist/commonjs/runtime in Traceur 0.0.110 #2126

Open
stuartZhang opened this issue May 31, 2016 · 7 comments
Open

Comments

@stuartZhang
Copy link

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.

  1. 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

  1. The traceur runtime has been introduced in the HTML page.
<script type="text/javascript" src="/js/traceur-runtime.js"></script>

The file "traceur-runtime.js" is copied from the folder "node_modules/traceur/bin".

  1. 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".

@stuartZhang
Copy link
Author

stuartZhang commented May 31, 2016

It's worth saying that, as for the traceur@0.0.107, the compilation-output ES5 JavaScript program works in the web browser.

Is it a regression bug for the version 0.0.110?

@johnjbarton
Copy link
Contributor

Please look in to your output for the $traceurRuntime.registerModule() with the name from your initTailRecursiveFunction.js. Also compare these with the the old and new versions of the compiler.

The compiler generates $traceurRuntime.registerModule() to store the modules and $traceurRuntime.getModule() to retrieve them. The register call must be missing or out of order.

Once you have a hint perhaps you can create a small test case. We did make some changes in the runtime.

@stuartZhang
Copy link
Author

stuartZhang commented Jun 1, 2016

Given my investigation, the Traceur@0.0.110-compilation ES5 code is very different from Traceur@0.0.107.

The below JS statement is inexistent in the Traceur@0.0.107 compilation result.
var $__continuation = $traceurRuntime.getModule($traceurRuntime.normalizeModuleName("traceur/dist/commonjs/runtime/modules/continuation.js", "widget-nest-thermostat.bbjs")).default;

On the contrary, in Traceur@0.0.110 compilation result, the above statement is in the 2nd line.

However, in the web browser, the above JS statement brings about a NullPointer error, because $traceurRuntime.getModule($traceurRuntime.normalizeModuleName("traceur/dist/commonjs/runtime/modules/continuation.js", "widget-nest-thermostat.bbjs")) return null.

The following picture shows the differences between Traceur@0.0.110 and Traceur@0.0.107 compilation results.

traceur_diff

@johnjbarton
Copy link
Contributor

Looks like continuation.js did not make it into the commonjs runtime.

@johnjbarton johnjbarton changed the title The ES5 code from Traceur 0.0.110 doesn't work in web browser. continuation.js missing from dist/commonjs/runtime in Traceur 0.0.110 Jun 1, 2016
@arv
Copy link
Collaborator

arv commented Jun 1, 2016

I see dist/commonjs/runtime/modules/continuation.js in the npm release.

I suspect there is cyclic dependency with the require that causes this to be undefined. I'll try to create a minimal test case.

For now you can turn off import-runtime or turn off proper-tail-calls to get you unblocked.

@richgilbank
Copy link

Hey folks, thanks for the continued work on the project! 💃
Just wanted to leave a note here for anyone else currently experiencing issues with this - turning off properTailCalls didn't seem to do the trick for me, but turning off importRuntime did. ¯\(ツ)/¯
ref: richgilbank/Scratch-JS@d0f2e7b#diff-402dfb8c015ea27de73101a0b8d9fc32R17

@stuartZhang
Copy link
Author

Cloud you please teach me what the feature "importRuntime" takes on during the transformation from ES 6 to ES 5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants