-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use a deterministic depth-first order when managing dependencies #2641
Conversation
d040afa
to
0a5820a
Compare
Thanks @ChadKillingsworth |
@blickly I haven't been able to create a repo case where base.js is ordered incorrectly. I did add a couple of test cases to prove dependency ordering is not dependent on the user provided input order. The one oddity I found was https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/JSModuleGraph.java#L542-L545 |
One other note: historical precedence adds moochers to the front of the entry point list and user defined entry points at the end. If moochers are traditionally tests, should this order be reversed? |
I'm seeing cases where this is incorrectly ordering base.js after other files. For example, with the following setup. // bootstrap.js
goog.require('foo'); // foo.js
goog.provide('foo');
goog.setTestOnly(); When running the compiler with sorting but no pruning with the files passed in the order: |
13f7c7f
to
9a8cd62
Compare
…in a deterministic depth-first order from entry points. Avoids a full parse on every input when CommonJS module processing is enabled. ES6 and CommonJS modules no longer generate synthetic goog.require and goog.provide calls. ES6 Module Transpilation no longer depends on Closure-Library primitives.
9a8cd62
to
c668ed7
Compare
OK, looks resolved in the current version. Thanks Chad! |
@blickly what's your priority for merging this? Angular can't release our version 5.0 right now because ES6 modules are broken. We are hoping to cut an RC next week and might need to escalate. |
We're working on an issue with some internal tests that have done some unusual things. |
Any estimate of how many tests, and how broken they are? Do you need help to land the CL? |
Sure, never hurts to have more help. Thanks! |
Could this behavior be cause by this bug? |
@Ramblurr Yes definitely |
@ChadKillingsworth good to know. I've checked out this PR and while the original error message is gone, I've ran into another one. See the edited portion of the SO question I just added. Could it still be related to this PR? |
*** Reason for rollback *** Need to roll this back to unblock rollback of #2641 *** Original change description *** Always transpile modules, even if the output language requested was ES6 or higher. Since the compiler outputs a single file, it doesn't make sense to leave the import/export statements alone, unless the input to the compiler was just a single file, which is very rare. This allows for projects that are using ES6 modules to pass --language_out=ES_2015 or higher. *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=172167855
*** Original change description *** When --dependency_mode is set to STRICT or LOOSE, order dependencies in a deterministic depth-first order from entry points. Avoids a full parse on every input when CommonJS module processing is enabled. ES6 and CommonJS modules no longer generate synthetic goog.require and goog.provide calls. ES6 Module Transpilation no longer depends on Closure-Library primitives. *** Reopens #2641 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=172176468
This PR was rolled back in 22240a5 after it broke some internal projects. @MatrixFrog is working on a fix. |
Warning: this is potentially a high-impact change.
Due to the history of ordering dependencies as scripts with
goog.provide
andgoog.require
calls, the dependency sorting could produce incorrect results when using ES6 or CommonJS modules. In addition, the regex based parsing of dependencies did not recognize destructuring imports that spanned more than one line - and these are quite common external to Google.This change begins with entry points and fully parses each dependency as discovered. The order a dependency reference is encountered is preserved and the module sorting later performed now honors that ordering.
Benefits of this change:
Side effects of this change:
Fixes #2590
Fixes #2535
Fixes #2559
Fixes #2362
Fixes #2247