Skip to content

Apply .meteorignore to node_modules in PackageSource#_findSources.#9800

Merged
benjamn merged 1 commit intodevelfrom
apply-.meteorignore-to-node_modules
Apr 5, 2018
Merged

Apply .meteorignore to node_modules in PackageSource#_findSources.#9800
benjamn merged 1 commit intodevelfrom
apply-.meteorignore-to-node_modules

Conversation

@benjamn
Copy link
Copy Markdown
Contributor

@benjamn benjamn commented Apr 5, 2018

Although there was a comment in this code about not applying .meteorignore files to the contents of node_modules directories, I'm pretty sure that was the wrong decision, because .meteorignore merely limits what Meteor tries to compile as application code, and does not actually modify or hide node_modules files from other parts of Meteor (or Node).

In other words, there's no harm in letting .meteorignore apply to node_modules, and there may be a LOT of benefit, because it allows the developer to fight back when compilation descends unexpectedly into an npm package that contains non-.js[on] files for which a compiler plugin has been registered, an obscure but not uncommon behavior originally intended to allow importing CSS assets from npm packages:

However, we now have a much more powerful tool for selectively compiling specific npm packages: #9771. In light of this new approach, we should probably remove the promiscuous node_modules compilation behavior altogether, as it might speed up rebuild times for many applications whose developers don't know or care that this behavior exists. For example, abandoning this behavior would prevent the problem reported here: #6950

In the meantime, this commit makes .meteorignore work for node_modules.

Although there was a comment in this code about not applying .meteorignore
files to the contents of node_modules directories, I'm pretty sure that
was the wrong decision, because .meteorignore merely limits what Meteor
tries to compile as application code, and does not actually modify or hide
node_modules files from other parts of Meteor (or Node).

In other words, there's no harm in letting .meteorignore apply to
node_modules, and there may be a LOT of benefit, because it allows the
developer to fight back when compilation descends unexpectedly into an npm
package that contains non-.js[on] files for which a compiler plugin has
been registered, an obscure but not uncommon behavior originally intended
to allow importing CSS assets from npm packages:

* #6037
* 43659ff
* a073280
* #5242
* #6846
* #7406

However, we now have a much more powerful tool for selectively compiling
specific npm packages: #9771. In light of this new approach, we should
probably remove the promiscuous node_modules compilation behavior
altogether, as it might speed up rebuild times for many applications whose
developers don't know or care that this behavior exists. For example,
abandoning this behavior would prevent the problem reported here:
#6950

In the meantime, this commit makes .meteorignore work for node_modules.
@benjamn benjamn added this to the Release 1.6.2 milestone Apr 5, 2018
@benjamn benjamn merged commit 5241d67 into devel Apr 5, 2018
benjamn pushed a commit that referenced this pull request Apr 18, 2018
This functionality was originally intended to allow importing
compiled-to-JS modules from `node_modules`, by precompiling any modules
found in top-level npm packages, as long as a Meteor compiler plugin was
registered for the module's file extension.

As discussed in #9800, this extra compilation burden can be non-trivial,
especially if you happen to install an npm package such as `less`, which
contains hundreds of `.less` files in the `node_modules/less/test/`
directory.

More generally, this functionality was an early attempt to enable
selective compilation of `node_modules` directories, but it was not a good
solution to that problem, because in almost all cases the extra
compilation was unwanted.

Meteor 1.7 (formerly known as 1.6.2) will give full control over selective
compilation of `node_modules` back to the application developer (#9771),
which should afford a much better solution to this problem. If you've
installed some `.less` or `.scss` or `.ts` files from npm into your
`node_modules` directory, just create a symlink to the package directory
within your application, and those modules will be compiled and become
importable by other JS modules, as if they were part of the application.
benjamn added a commit that referenced this pull request Apr 18, 2018
…#9825)

This functionality was originally intended to allow importing
compiled-to-JS modules from `node_modules`, by precompiling any modules
found in top-level npm packages, as long as a Meteor compiler plugin was
registered for the module's file extension.

As discussed in #9800, this extra compilation burden can be non-trivial,
especially if you happen to install an npm package such as `less`, which
contains hundreds of `.less` files in the `node_modules/less/test/`
directory.

More generally, this functionality was an early attempt to enable
selective compilation of `node_modules` directories, but it was not a good
solution to that problem, because in almost all cases the extra
compilation was unwanted.

Meteor 1.7 (formerly known as 1.6.2) will give full control over selective
compilation of `node_modules` back to the application developer (#9771),
which should afford a much better solution to this problem. If you've
installed some `.less` or `.scss` or `.ts` files from npm into your
`node_modules` directory, just create a symlink to the package directory
within your application, and those modules will be compiled and become
importable by other JS modules, as if they were part of the application.
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.

1 participant