Skip to content

Conversation

@juj
Copy link
Collaborator

@juj juj commented Dec 8, 2019

Removes Closure from tree. Also remove test_sanity.test_closure_compiler, that is somewhat extraneous. The function check_closure_compiler is well enough, and is run whenever one enables closure with --closure 1.

@hujiajie
Copy link
Contributor

hujiajie commented Dec 9, 2019

Is there any plan to migrate other in-tree node modules (third_party/html-minifier, tools/eliminator, etc.) to npm install as well? If yes, does it mean python packages (e.g. third_party/ply) should be shipped via pip install similarly?

@sbc100
Copy link
Collaborator

sbc100 commented Dec 9, 2019

Is there any plan to migrate other in-tree node modules (third_party/html-minifier, tools/eliminator, etc.) to npm install as well? If yes, does it mean python packages (e.g. third_party/ply) should be shipped via pip install similarly?

In the long term yes, I think both these things would be good. One step at time though.

@juj
Copy link
Collaborator Author

juj commented Dec 9, 2019

Is there any plan to migrate other in-tree node modules (third_party/html-minifier

#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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replying to this in emsdk/404

@juj juj force-pushed the closure_via_npm_install branch from fdc0346 to 337a554 Compare December 10, 2019 17:34
@juj
Copy link
Collaborator Author

juj commented Dec 10, 2019

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 node is not found when running closure compiler. I am not at all sure what is going on there, since node is added to PATH https://github.com/emscripten-core/emscripten/pull/9989/files#diff-1d37e48f9ceff6d8030570cd36286a61R96 , the next line installs closure compiler, so that PATH addition must be taking effect as well?

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry.. that should be "emsdk-master" with a hyphen

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to split this off here: #10254.. hope you don't mind me being proactive here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok this part has landed now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this?

@juj juj force-pushed the closure_via_npm_install branch 2 times, most recently from 97d85f3 to 7bd783e Compare December 15, 2019 14:20
@juj
Copy link
Collaborator Author

juj commented Jan 9, 2020

Ping @kripken on this - after emscripten-core/emsdk#404 lands, this should pass the suite and be good to land as well.

@kripken
Copy link
Member

kripken commented Jan 9, 2020

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.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 9, 2020

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.

@juj juj force-pushed the closure_via_npm_install branch from 7bd783e to fc9ebeb Compare January 10, 2020 20:13
@juj juj changed the base branch from incoming to master January 14, 2020 18:57
@juj juj force-pushed the closure_via_npm_install branch from fc9ebeb to b29140f Compare January 18, 2020 12:07
@sbc100
Copy link
Collaborator

sbc100 commented Jan 21, 2020

Before we land this can we first transition the existing checked-in content of node_modules at the top level? Currently I think it just hold ws. So I think it would just be questions of git rm -r node_modules. I'd rather not be in a situation where we have both npm and git managing files in that location.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 21, 2020

I'm happy to propose that change if you like?

@sbc100
Copy link
Collaborator

sbc100 commented Jan 21, 2020

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ''))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should be able to use "npx google-closure-compiler" here to avoid the internal knowledge of the layout.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


# 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 }}}'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about leaving this alone then? Any reason not to leave it as a comment? Seems like this line could just be reverted.

sbc100 added a commit that referenced this pull request Jan 21, 2020
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.
sbc100 added a commit that referenced this pull request Jan 22, 2020
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.
sbc100 added a commit that referenced this pull request Jan 22, 2020
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.
sbc100 added a commit that referenced this pull request Jan 22, 2020
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.
@juj juj force-pushed the closure_via_npm_install branch from 180fffb to c59ad64 Compare January 23, 2020 15:20
@juj
Copy link
Collaborator Author

juj commented Jan 23, 2020

Rebased to master, let's see how the CI likes this now.

Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with a couple of last comments.

Excited to see this happen!


# 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 }}}'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ''))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this?

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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@juj juj force-pushed the closure_via_npm_install branch 2 times, most recently from 5b3585a to 7656639 Compare January 25, 2020 18:25
@juj juj force-pushed the closure_via_npm_install branch from 0ccb42b to 04e921f Compare January 26, 2020 11:18
@juj juj force-pushed the closure_via_npm_install branch from 04e921f to e7d1cde Compare January 26, 2020 12:30
@juj juj merged commit b5ec625 into emscripten-core:master Jan 26, 2020
@kripken
Copy link
Member

kripken commented Jan 27, 2020

This appears to have broken the chromium CI roll,

https://ci.chromium.org/p/emscripten-releases/builders/try/linux/b8890100283367924880

due to errors like

shared:WARNING: Closure compiler (['/b/s/w/ir/cache/builder/emscripten-releases/node-v12.9.1-linux-x64/bin/node', '--max_old_space_size=8192', '/b/s/w/ir/k/install/emscripten/node_modules/.bin/google-closure-compiler']) does not exist, check the paths in /b/s/w/ir/k/install/emscripten_config_upstream. To install Closure compiler, run "npm install" in Emscripten root directory.

It looks like closure was not installed or not installed successfully using the new method?

cc @juj @sbc100

sbc100 added a commit that referenced this pull request Jan 27, 2020
A followup on #9989.  The only two calls sites call exit_with_error if
this function fails so just make all errors here fatal.
@sbc100
Copy link
Collaborator

sbc100 commented Jan 27, 2020

Fix ed in WebAssembly/waterfall#618

sbc100 added a commit that referenced this pull request Jan 27, 2020
A followup on #9989.  The only two calls sites call exit_with_error if
this function fails so just make all errors here fatal.
sbc100 added a commit that referenced this pull request Feb 14, 2020
This should have been part of #9989 but we somehow forgot to add it.
sbc100 added a commit that referenced this pull request Feb 14, 2020
This should have been part of #9989 but we somehow forgot to add it.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 18, 2024
This workaround was added in emscripten-core#9989, I assume because one or more tests
failed without.
sbc100 added a commit that referenced this pull request Sep 24, 2024
This workaround was added in #9989, I assume because one or more tests
failed without.
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

Successfully merging this pull request may close these issues.

4 participants