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

Commit 32e4841

Browse files
committed
refactor(optimization): update the optimization loader to handle lazy-loaded modules
1 parent 3df19bf commit 32e4841

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/webpack/optimization-loader-impl.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { normalize, resolve } from 'path';
2-
import { getContext, isSrcOrIonicOrIonicDeps } from '../util/helpers';
1+
import { extname, normalize, resolve } from 'path';
2+
import { changeExtension, getContext, isSrcOrIonicOrIonicDeps } from '../util/helpers';
33
import { Logger } from '../logger/logger';
44

55
/* This loader is purely for caching stuff */
@@ -9,6 +9,11 @@ export function optimizationLoader(source: string, map: any, webpackContex: any)
99
var callback = webpackContex.async();
1010

1111
const absolutePath = resolve(normalize(webpackContex.resourcePath));
12+
if (extname(absolutePath) === '.ts') {
13+
const jsFilePath = changeExtension(absolutePath, '.js');
14+
const jsFile = context.fileCache.get(jsFilePath);
15+
source = jsFile.content;
16+
}
1217

1318
Logger.debug(`[Webpack] optimization: processing the following file: ${absolutePath}`);
1419

0 commit comments

Comments
 (0)