mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Watch all imported files in linked npm packages on server.
This commit is contained in:
@@ -74,7 +74,7 @@ function makeOptimistic(name, fn) {
|
||||
return Profile("optimistic " + name, wrapper);
|
||||
}
|
||||
|
||||
function shouldWatch(path) {
|
||||
export const shouldWatch = wrap(path => {
|
||||
const parts = path.split(pathSep);
|
||||
const nmi = parts.indexOf("node_modules");
|
||||
|
||||
@@ -113,7 +113,7 @@ function shouldWatch(path) {
|
||||
// instead we rely on dependOnNodeModules to tell us when files in
|
||||
// node_modules directories might have changed.
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
function maybeDependOnNodeModules(path) {
|
||||
if (typeof path !== "string") {
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
optimisticReadFile,
|
||||
optimisticStatOrNull,
|
||||
optimisticHashOrNull,
|
||||
shouldWatch,
|
||||
} from "../fs/optimistic.js";
|
||||
|
||||
import Resolver from "./resolver.js";
|
||||
@@ -557,11 +558,19 @@ export default class ImportScanner {
|
||||
// Append this file to the output array and record its index.
|
||||
this._addFile(absImportedPath, depFile);
|
||||
|
||||
// On the server, modules in node_modules directories will be
|
||||
// handled natively by Node, so we don't need to build a
|
||||
// meteorInstall-style bundle beyond the entry-point module.
|
||||
if (! this.isWeb() &&
|
||||
depFile.installPath.startsWith("node_modules/")) {
|
||||
// On the server, modules in node_modules directories will be
|
||||
// handled natively by Node, so we don't need to build a
|
||||
// meteorInstall-style bundle beyond the entry-point module.
|
||||
depFile.installPath.startsWith("node_modules/") &&
|
||||
// If optimistic functions care about this file, e.g. because it
|
||||
// resides in a linked npm package, then we should allow it to
|
||||
// be watched by including it in the server bundle by not
|
||||
// returning here. Note that inclusion in the server bundle is
|
||||
// an unnecessary consequence of this logic, since Node will
|
||||
// still evaluate this module natively on the server. What we
|
||||
// really care about is watching the file for changes.
|
||||
! shouldWatch(absImportedPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user