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

Commit

Permalink
feat: add forceIsolatedModules
Browse files Browse the repository at this point in the history
  • Loading branch information
s-panferov committed Nov 1, 2017
1 parent 83e0e83 commit 7f74bba
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -108,6 +108,8 @@ Please note that ATL works **the same way as a TypeScript compiler** as much as

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

**ADVICE**: The loader works faster if you use `isolatedModules` or `forceIsolatedModules` options.

## Loader options

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

Use this setting to disable type checking.

### forceIsolatedModules *(boolean)*

Use this setting to disable dependent module recompilation.

### ignoreDiagnostics *(number[]) (default=[])*

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.
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Expand Up @@ -93,14 +93,19 @@ function compiler(loader: Loader, text: string): void {

transformation
.then(({cached, result}) => {
if (!instance.compilerConfig.options.isolatedModules && result.deps) {
const isolated =
instance.loaderConfig.forceIsolatedModules ||
instance.compilerConfig.options.isolatedModules;

if (!isolated && result.deps) {
// If our modules are isolated we don't need to recompile all the deps
result.deps.forEach(dep => loader.addDependency(path.normalize(dep)));
}
if (cached) {
// Update file in checker in case we read it from the cache
instance.checker.updateFile(fileName, text);
}

return result;
})
.then(({text, map}) => {
Expand Down
3 changes: 3 additions & 0 deletions src/instance.ts
Expand Up @@ -39,6 +39,9 @@ export interface Compiler {

export interface Loader {
_compiler: Compiler;
_module: {
meta: any
};
cacheable: () => void;
query: string;
async: () => (err: Error, source?: string, map?: string) => void;
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Expand Up @@ -11,6 +11,7 @@ export interface LoaderConfig {
compiler?: string;
configFileName?: string;
configFileContent?: string;
forceIsolatedModules?: boolean;
transpileOnly?: boolean;
ignoreDiagnostics?: number[];
compilerOptions?: ts.CompilerOptions;
Expand Down

0 comments on commit 7f74bba

Please sign in to comment.