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

Commit 7f74bba

Browse files
committed
feat: add forceIsolatedModules
1 parent 83e0e83 commit 7f74bba

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ Please note that ATL works **the same way as a TypeScript compiler** as much as
108108

109109
**ADVICE**: Typically you want your `files` section to include only entry points.
110110

111+
**ADVICE**: The loader works faster if you use `isolatedModules` or `forceIsolatedModules` options.
112+
111113
## Loader options
112114

113115
### silent *(boolean) (default=false)*
@@ -138,6 +140,10 @@ Specifies the path to a TS config file. This is useful when you have multiple co
138140

139141
Use this setting to disable type checking.
140142

143+
### forceIsolatedModules *(boolean)*
144+
145+
Use this setting to disable dependent module recompilation.
146+
141147
### ignoreDiagnostics *(number[]) (default=[])*
142148

143149
You can squelch certain TypeScript errors by specifying an array of [diagnostic codes](https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json) to ignore.

src/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,19 @@ function compiler(loader: Loader, text: string): void {
9393

9494
transformation
9595
.then(({cached, result}) => {
96-
if (!instance.compilerConfig.options.isolatedModules && result.deps) {
96+
const isolated =
97+
instance.loaderConfig.forceIsolatedModules ||
98+
instance.compilerConfig.options.isolatedModules;
99+
100+
if (!isolated && result.deps) {
97101
// If our modules are isolated we don't need to recompile all the deps
98102
result.deps.forEach(dep => loader.addDependency(path.normalize(dep)));
99103
}
100104
if (cached) {
101105
// Update file in checker in case we read it from the cache
102106
instance.checker.updateFile(fileName, text);
103107
}
108+
104109
return result;
105110
})
106111
.then(({text, map}) => {

src/instance.ts

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export interface Compiler {
3939

4040
export interface Loader {
4141
_compiler: Compiler;
42+
_module: {
43+
meta: any
44+
};
4245
cacheable: () => void;
4346
query: string;
4447
async: () => (err: Error, source?: string, map?: string) => void;

src/interfaces.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface LoaderConfig {
1111
compiler?: string;
1212
configFileName?: string;
1313
configFileContent?: string;
14+
forceIsolatedModules?: boolean;
1415
transpileOnly?: boolean;
1516
ignoreDiagnostics?: number[];
1617
compilerOptions?: ts.CompilerOptions;

0 commit comments

Comments
 (0)