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

Using --no-bundle-external and NODE_PATH #1857

Open
spacejack opened this issue Aug 5, 2018 · 9 comments
Open

Using --no-bundle-external and NODE_PATH #1857

spacejack opened this issue Aug 5, 2018 · 9 comments

Comments

@spacejack
Copy link

spacejack commented Aug 5, 2018

Hi, I'm trying to create a single bundle for a node app. I want to omit node_modules from the budle, so I use --no-bundle-external. And I'm using NODE_PATH=common to avoid a lot of require('../../..

Unfortunately it omits everything from common/ from the bundle. Is there a way to get it to just omit node_modules and native node libs (fs, path, etc.) but include my app's common files?

The only way I've got it to work so far is to manually list everything to exclude with -u foo -u bar ... which is not ideal. Any other options?

@ljharb
Copy link
Member

ljharb commented Aug 5, 2018

NODE_PATH is deprecated anyways; I’d suggest using babel to rewrite import paths, or to use a symlink in node_modules.

@spacejack
Copy link
Author

Thanks for the suggestions @ljharb.

I'm using Typescript which I don't believe does path rewriting for you; it defers that task to the bundler unfortunately.

Adding symlinks to node_modules doesn't sound like it would work? I think browserify would definitely ignore those modules in that case.

@ljharb
Copy link
Member

ljharb commented Aug 5, 2018

You can use babel with typescript now, and only use tsc for typechecking.

@sternenseemann
Copy link

See also #1626 and browserify/resolve#47. NODE_PATH support seems to have been dropped.

@ljharb
Copy link
Member

ljharb commented Jul 21, 2020

When did it work?

NODE_PATH has been community-deprecated for many, many years; i wasn't aware browserify ever supported it.

@sternenseemann
Copy link

I don't know actually, but the browserify documentation currently states that it does work — and in multiple places at that. See:

@ljharb
Copy link
Member

ljharb commented Jul 21, 2020

I understand that, but it's important to figure out if the documentation was just always wrong, or if actual support for NODE_PATH was removed intentionally or unintentionally.

@sternenseemann
Copy link

The close in resolve indicates that, I'd say, but I suppose there is also a possibility this is an unintentional regression in browserify and it is indeed a bug (I'd actually love for this to get fixed).

@ljharb
Copy link
Member

ljharb commented Jul 21, 2020

Since nobody should ever be using NODE_PATH ever for any reason, I'd prefer it not get fixed, but if it was unintentionally dropped that's a viable argument to fix it.

You may want to test various versions of browserify to determine this.

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

No branches or pull requests

3 participants