Skip to content

Commit 4366b1c

Browse files
committed
node_modules is not watched by default
If you want to watch for changes in node_modules or package.json a --sync-all-files or --syncAllFiles flag needs to be passed. By default only the app/ folder is being watched during any livesync. watch only production node_modules
1 parent 99e1ad6 commit 4366b1c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/options.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class Options extends commonOptionsLibPath.OptionsBase {
3939
bundle: { type: OptionType.Boolean },
4040
all: { type: OptionType.Boolean },
4141
teamId: { type: OptionType.String },
42-
syncAllFiles: { type: OptionType.Boolean, default: true },
42+
syncAllFiles: { type: OptionType.Boolean, default: false },
4343
liveEdit: { type: OptionType.Boolean },
4444
chrome: { type: OptionType.Boolean },
4545
clean: { type: OptionType.Boolean },

lib/services/livesync/livesync-service.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as helpers from "../../common/helpers";
33
import * as path from "path";
44
import * as semver from "semver";
55
import * as fiberBootstrap from "../../common/fiber-bootstrap";
6+
import { NodeModulesDependenciesBuilder } from "../../tools/node-modules/node-modules-dependencies-builder";
7+
68
let choki = require("chokidar");
79

810
class LiveSyncService implements ILiveSyncService {
@@ -117,7 +119,19 @@ class LiveSyncService implements ILiveSyncService {
117119

118120
private partialSync(syncWorkingDirectory: string, onChangedActions: ((event: string, filePath: string, dispatcher: IFutureDispatcher) => void )[]): void {
119121
let that = this;
120-
let pattern = ["app", "package.json", "node_modules"];
122+
let dependenciesBuilder = this.$injector.resolve(NodeModulesDependenciesBuilder, {});
123+
let productionDependencies = dependenciesBuilder.getProductionDependencies(this.$projectData.projectDir);
124+
let pattern = ["app"];
125+
126+
if(this.$options.syncAllFiles) {
127+
pattern.push("package.json");
128+
129+
// watch only production node_module/packages same one prepare uses
130+
for(let index in productionDependencies) {
131+
pattern.push("node_modules/" + productionDependencies[index].name);
132+
}
133+
}
134+
121135
let watcher = choki.watch(pattern, { ignoreInitial: true, cwd: syncWorkingDirectory }).on("all", (event: string, filePath: string) => {
122136
fiberBootstrap.run(() => {
123137
that.$dispatcher.dispatch(() => (() => {

0 commit comments

Comments
 (0)