This repository has been archived by the owner on Aug 7, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support platform specific files that are not directly imported a…
…nywhere in the app (#843) * fix: support platform specific files that are not directly imported anywhere in the app (e.g. when main.ts is platform specific). * fix: support platform specific entry modules
- Loading branch information
Dimitar Tachev
authored
Apr 1, 2019
1 parent
7034a97
commit e1e9463
Showing
8 changed files
with
51 additions
and
12 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { parse, join } from "path"; | ||
import { AngularCompilerPlugin } from "@ngtools/webpack"; | ||
|
||
export function getAngularCompilerPlugin(platform: string): any { | ||
class NativeScriptAngularCompilerPlugin extends AngularCompilerPlugin { | ||
// This is the bridge between the @ngtols/webpack loader and the AngularCompilerPlugin plugin itself: | ||
// https://github.com/angular/angular-cli/blob/bf52b26219ffc16bed2dd55716e21773b415fd2a/packages/ngtools/webpack/src/loader.ts#L49 | ||
// The problem is that the loader does not call the `hostReplacementPaths` method when asking for the compiledFile. | ||
// By overriding this method, we work around this issue and support platform specific files from the loader | ||
// that are not compiled by the AngularCompilerPlugin plugin. e.g. main.ts is the webpack entry point and | ||
// it's loaded by the @ngtools/webpack loader but its not compiled by the plugin because the TypeScript Compiler | ||
// knowns only about main.android.ts and main.ios.ts (main.ts is not imported/required anywhere in the app). | ||
getCompiledFile(file) { | ||
try { | ||
if (platform) { | ||
const parsed = parse(file); | ||
const platformFile = join(parsed.dir, `${parsed.name}.${platform}${parsed.ext}`); | ||
return super.getCompiledFile(platformFile); | ||
} | ||
} | ||
catch (e) { } | ||
|
||
return super.getCompiledFile(file); | ||
} | ||
} | ||
|
||
return NativeScriptAngularCompilerPlugin; | ||
} |
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
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
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