This repository has been archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(): always serve latest file changes (#1521)
When running `ionic serve` it often happens that the transpiled files become out of date. After making a change to one of the TypeScript source files, ionic serve runs, but when looking at the built JavaScript files, the new code is not present. I found that the app-scripts build process kept two file caches. One in the app-script context and one in the so called InMemoryCompilerHost. The first was updated when files changed, but the latter wasn't. The InMemoryCompilerHost is in my opinion superfluous, because it got injected a HybridFileSystem, which nicely uses the app-scripts context fileCache. My solution is to rename the InMemoryCompilerHost to FileSystemCompilerHost and let the injected HybridFileSystem handle the caching. This solution not only fixes the out-of-date-files issue, but also redecuses memory usage of app-scripts.
- Loading branch information
1 parent
5d7ca38
commit 266a871
Showing
4 changed files
with
11 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { CompilerOptions } from 'typescript'; | ||
import { InMemoryCompilerHost } from './compiler-host'; | ||
import { FileSystemCompilerHost } from './compiler-host'; | ||
import { getInstance as getFileSystemInstance } from '../util/hybrid-file-system-factory'; | ||
|
||
let instance: InMemoryCompilerHost = null; | ||
let instance: FileSystemCompilerHost = null; | ||
|
||
export function getInMemoryCompilerHostInstance(options: CompilerOptions) { | ||
export function getFileSystemCompilerHostInstance(options: CompilerOptions) { | ||
if (!instance) { | ||
instance = new InMemoryCompilerHost(options, getFileSystemInstance(false)); | ||
instance = new FileSystemCompilerHost(options, getFileSystemInstance(false)); | ||
} | ||
return instance; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
266a871
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This's been bugging us for year(s)... 👏