Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit a8616eb

Browse files
committed
refactor(webpack): only pass changed files to webpack that are src files and have a .ts extension
1 parent 47f43f2 commit a8616eb

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/webpack/ionic-environment-plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export class IonicEnvironmentPlugin {
1515
apply(compiler: any) {
1616

1717
compiler.plugin('context-module-factory', (contextModuleFactory: any) => {
18-
const deepLinkConfig = getParsedDeepLinkConfig();
19-
const webpackDeepLinkModuleDictionary = convertDeepLinkConfigToWebpackFormat(deepLinkConfig);
2018
contextModuleFactory.plugin('after-resolve', (result: any, callback: Function) => {
2119
if (!result) {
2220
return callback();
2321
}
2422

23+
const deepLinkConfig = getParsedDeepLinkConfig();
24+
const webpackDeepLinkModuleDictionary = convertDeepLinkConfigToWebpackFormat(deepLinkConfig);
2525
const ionicAngularDir = getStringPropertyValue(Constants.ENV_VAR_IONIC_ANGULAR_DIR);
2626
const ngModuleLoaderDirectory = join(ionicAngularDir, 'util');
2727
if (!result.resource.endsWith(ngModuleLoaderDirectory)) {
@@ -52,7 +52,7 @@ export class IonicEnvironmentPlugin {
5252
hybridFileSystem.setFileSystem(compiler.inputFileSystem);
5353
compiler.inputFileSystem = hybridFileSystem;
5454
compiler.outputFileSystem = hybridFileSystem;
55-
compiler.watchFileSystem = new WatchMemorySystem(this.context.fileCache);
55+
compiler.watchFileSystem = new WatchMemorySystem(this.context.fileCache, this.context.srcDir);
5656

5757
// do a bunch of webpack specific stuff here, so cast to an any
5858
// populate the content of the file system with any virtual files

src/webpack/watch-memory-system.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { extname } from 'path';
12
import { FileCache } from '../util/file-cache';
23
import { on, EventType } from '../util/events';
34
import { Logger } from '../logger/logger';
@@ -17,7 +18,7 @@ export class WatchMemorySystem {
1718
private immediateCallback: (filePath: string, timestamp: number) => void;
1819
private aggregatedCallback: (err: Error, changesFilePaths: string[], dirPaths: string[], missingPaths: string[], timesOne: any, timesTwo: any) => void;
1920

20-
constructor(private fileCache: FileCache) {
21+
constructor(private fileCache: FileCache, private srcDir: string) {
2122
}
2223

2324
close() {
@@ -52,7 +53,7 @@ export class WatchMemorySystem {
5253
this.isListening = true;
5354
on(EventType.WebpackFilesChanged, () => {
5455
this.changes = new Set<string>();
55-
const filePaths = this.fileCache.getAll().filter(file => file.timestamp >= this.lastWatchEventTimestamp).map(file => file.path);
56+
const filePaths = this.fileCache.getAll().filter(file => file.timestamp >= this.lastWatchEventTimestamp && file.path.startsWith(this.srcDir) && extname(file.path) === '.ts').map(file => file.path);
5657
Logger.debug('filePaths: ', filePaths);
5758
this.lastWatchEventTimestamp = Date.now();
5859
this.processChanges(filePaths);

0 commit comments

Comments
 (0)