Migrate Closure to be located via npm install#9989
Migrate Closure to be located via npm install#9989juj merged 7 commits intoemscripten-core:masterfrom
Conversation
0f3dbaf to
2a5155b
Compare
|
Is there any plan to migrate other in-tree node modules ( |
In the long term yes, I think both these things would be good. One step at time though. |
#9990 migrates html-minifier. |
| tar -xf node-v12.13.0-linux-x64.tar.xz | ||
| export PATH="`pwd`/node-v12.13.0-linux-x64/bin:${PATH}" | ||
| npm install | ||
| - run: |
There was a problem hiding this comment.
I don't see a full explanation of the plan here, so I'm not sure who we expect to run npm install, exactly?
From this change to circleCI, it seems like this direction implies all users, even emsdk users, will need to install npm and run npm install? If so that worries me.
There was a problem hiding this comment.
No, emsdk users will get this as a part of post-install.
Direct git users will need to run npm install, but we can prompt them to do this if they forget. We will of course need to document this clearly and mention both on the mailing list and in the ChangeLog. One nice thing about doing it with closure first is that it only effects our users who use closure, so it will be a good way to test the waters without effecting all users right away.
There was a problem hiding this comment.
Another nice thing about making this a post-install step and not trying to bundle it is that the npm install can do all kind of platform specific things such as building native executables if needs be. With a bundled version we wouldn't have that option (unless we want commit bundle N different platform bundles)
There was a problem hiding this comment.
I think we should talk about this suggestion to use npm in a more general way, as I still don't think I see the big picture. I see @juj posted a long comment in emscripten-core/emsdk#404 (comment) - maybe we should consolidate the discussion there?
As to that last point, though - why would native executables matter for closure or other JS things? Or is there some future use of native executables you envision?
There was a problem hiding this comment.
Replying to this in emsdk/404
fdc0346 to
337a554
Compare
|
Hmm, the PR is now in a state where it passes locally on my Windows, Linux and Mac computers. However on the CI it is still failing with saying |
.circleci/config.yml
Outdated
| wget https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x64.tar.xz | ||
| tar -xf node-v12.13.0-linux-x64.tar.xz | ||
| export PATH="`pwd`/node-v12.13.0-linux-x64/bin:${PATH}" | ||
| npm install |
There was a problem hiding this comment.
We already have node installed as part of emsdk above, right?
Hopefully we can do something like:
source emsdk_master/emsdk_env.sh
NODE_DIR=$(dirname $EMSDK_NODE)
export PATH=$NODE_DIR:$PATH
There was a problem hiding this comment.
Hmm, not sure at all. Changed to that. I do see emsdk in https://github.com/emscripten-core/emscripten/blob/incoming/.circleci/config.yml#L23 , but that does not seem to help. Switched to using the above in 2d6fc43 but it is not locating emsdk there.
There was a problem hiding this comment.
Sorry.. that should be "emsdk-master" with a hyphen
There was a problem hiding this comment.
Lets see if we can land this part separately. We already run npm install ws in test-upstream-sockets-chrome.. we should probably just move that code here and remove the ws so it follows the package.json.
There was a problem hiding this comment.
I tried to split this off here: #10254.. hope you don't mind me being proactive here.
There was a problem hiding this comment.
Ok this part has landed now.
97d85f3 to
7bd783e
Compare
|
Ping @kripken on this - after emscripten-core/emsdk#404 lands, this should pass the suite and be good to land as well. |
|
Same thoughts as the other issue - if you and @sbc100 are confident in being able to handle fallout from landing these things now, then lgtm. |
|
The good thing about landing the emsdk change first, and holding back the emscripten-side change, is that we can see if emsdk user report issues and revert if needed. I suggest we wait a couple of weeks after the emsdk change lands before depending on it. |
7bd783e to
fc9ebeb
Compare
fc9ebeb to
b29140f
Compare
|
Before we land this can we first transition the existing checked-in content of |
|
I'm happy to propose that change if you like? |
|
Sorry, ignore those last two comments. Looks like I was wrong and we have never had node_modules in git at the top level. Not sure why I believed that to be true.. |
| except Exception as e: | ||
| warning('Closure compiler ("%s --version") did not execute properly!' % CLOSURE_COMPILER) | ||
| warning(str(e)) | ||
| return False |
There was a problem hiding this comment.
I think maybe we should switch this over to only checking on demand, rather than on startup/sanity, but thats a separate change.
tools/shared.py
Outdated
|
|
||
| if CLOSURE_COMPILER is None: | ||
| CLOSURE_COMPILER = path_from_root('third_party', 'closure-compiler', 'compiler.jar') | ||
| CLOSURE_COMPILER = path_from_root('node_modules', '.bin', 'google-closure-compiler' + ('.cmd' if WINDOWS else '')) |
There was a problem hiding this comment.
I feel like we should be able to use "npx google-closure-compiler" here to avoid the internal knowledge of the layout.
There was a problem hiding this comment.
npx has many more moving pieces, such as install-on-demand if the package does not exist. I like this explicit behavior better. Since we are not dealing with randomly updating package, and Closure is quite stable, I don't think this is much of an issue.
There was a problem hiding this comment.
OK, I agree that maybe npx is more than we want. But once this lands i would like to find a better solution. IIUC pocking directly into the .bin directory is not recommend as that is npm/node implementation detail.
I did a little research and foudn this: https://2ality.com/2016/01/locally-installed-npm-executables.html
Seems like maybe npm bin is the way to get access to that path.
tools/settings_template.py
Outdated
|
|
||
| # CLOSURE_COMPILER = '..' # define this to not use the bundled version | ||
| # To install Closure compiler, run 'npm install' in Emscripten root directory | ||
| CLOSURE_COMPILER = '{{{ CLOSURE_COMPILER }}}' |
There was a problem hiding this comment.
Should we just remove this line completely from the config? Do we want to support non-standard locations/configurations for closure compiler? I'm tempted to say no.
There was a problem hiding this comment.
I don't want to break existing users. No idea how that came to be, but I'll leave that for later, if someone wants to drop this. (no idea if someone might break if that is removed, but I think that's for separate topic)
There was a problem hiding this comment.
What about leaving this alone then? Any reason not to leave it as a comment? Seems like this line could just be reverted.
emsdk will run npm install in the version of emscripten that it downloads, but we override with our own version from git and we need to run `npm install` locally. Previously we only did this for the socket tests which are currently the only parts of emscripten that actually depend on `npm install` having been run. However we have plans to extend that. See #9989.
emsdk will run npm install in the version of emscripten that it downloads, but we override with our own version from git and we need to run `npm install` locally. Previously we only did this for the socket tests which are currently the only parts of emscripten that actually depend on `npm install` having been run. However we have plans to extend that. See #9989.
emsdk will run npm install in the version of emscripten that it downloads, but we override with our own version from git and we need to run `npm install` locally. Previously we only did this for the socket tests which are currently the only parts of emscripten that actually depend on `npm install` having been run. However we have plans to extend that. See #9989.
emsdk will run npm install in the version of emscripten that it downloads, but we override with our own version from git and we need to run `npm install` locally. Previously we only did this for the socket tests which are currently the only parts of emscripten that actually depend on `npm install` having been run. However we have plans to extend that. See #9989.
180fffb to
c59ad64
Compare
|
Rebased to master, let's see how the CI likes this now. |
sbc100
left a comment
There was a problem hiding this comment.
lgtm with a couple of last comments.
Excited to see this happen!
tools/settings_template.py
Outdated
|
|
||
| # CLOSURE_COMPILER = '..' # define this to not use the bundled version | ||
| # To install Closure compiler, run 'npm install' in Emscripten root directory | ||
| CLOSURE_COMPILER = '{{{ CLOSURE_COMPILER }}}' |
There was a problem hiding this comment.
What about leaving this alone then? Any reason not to leave it as a comment? Seems like this line could just be reverted.
tools/shared.py
Outdated
|
|
||
| if CLOSURE_COMPILER is None: | ||
| CLOSURE_COMPILER = path_from_root('third_party', 'closure-compiler', 'compiler.jar') | ||
| CLOSURE_COMPILER = path_from_root('node_modules', '.bin', 'google-closure-compiler' + ('.cmd' if WINDOWS else '')) |
There was a problem hiding this comment.
OK, I agree that maybe npx is more than we want. But once this lands i would like to find a better solution. IIUC pocking directly into the .bin directory is not recommend as that is npm/node implementation detail.
I did a little research and foudn this: https://2ality.com/2016/01/locally-installed-npm-executables.html
Seems like maybe npm bin is the way to get access to that path.
.circleci/config.yml
Outdated
| wget https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x64.tar.xz | ||
| tar -xf node-v12.13.0-linux-x64.tar.xz | ||
| export PATH="`pwd`/node-v12.13.0-linux-x64/bin:${PATH}" | ||
| npm install |
tests/runner.py
Outdated
| if os.environ.get('NODE_PATH'): | ||
| os.environ['NODE_PATH'] = os.environ['NODE_PATH'] + os.pathsep + path_from_root('node_modules') | ||
| else: | ||
| os.environ['NODE_PATH'] = path_from_root('node_modules') |
There was a problem hiding this comment.
I just moved this code to test_sockets.py in #10266. My apologies for the churn, I probably should have waited until you landed this change.
5b3585a to
7656639
Compare
0ccb42b to
04e921f
Compare
04e921f to
e7d1cde
Compare
|
This appears to have broken the chromium CI roll, https://ci.chromium.org/p/emscripten-releases/builders/try/linux/b8890100283367924880 due to errors like It looks like closure was not installed or not installed successfully using the new method? |
A followup on #9989. The only two calls sites call exit_with_error if this function fails so just make all errors here fatal.
|
Fix ed in WebAssembly/waterfall#618 |
A followup on #9989. The only two calls sites call exit_with_error if this function fails so just make all errors here fatal.
This should have been part of #9989 but we somehow forgot to add it.
This should have been part of #9989 but we somehow forgot to add it.
This workaround was added in emscripten-core#9989, I assume because one or more tests failed without.
This workaround was added in #9989, I assume because one or more tests failed without.
Removes Closure from tree. Also remove test_sanity.test_closure_compiler, that is somewhat extraneous. The function
check_closure_compileris well enough, and is run whenever one enables closure with--closure 1.