@ngtools/webpack 12.1.0-next.3 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +4 -4
- package/src/index.js +24 -2
- package/src/inline-data-loader.d.ts +1 -1
- package/src/inline-data-loader.js +1 -1
- package/src/ivy/host.js +21 -7
- package/src/ivy/loader.d.ts +4 -1
- package/src/ivy/loader.js +23 -7
- package/src/ivy/paths.js +20 -1
- package/src/ivy/plugin.d.ts +3 -1
- package/src/ivy/plugin.js +53 -20
- package/src/ivy/symbol.js +22 -24
- package/src/ivy/system.js +20 -1
- package/src/ivy/transformation.js +23 -4
- package/src/ngcc_processor.d.ts +3 -3
- package/src/ngcc_processor.js +25 -17
- package/src/paths-plugin.d.ts +1 -1
- package/src/paths-plugin.js +53 -24
- package/src/resource_loader.d.ts +1 -2
- package/src/resource_loader.js +34 -23
- package/src/transformers/elide_imports.d.ts +1 -2
- package/src/transformers/elide_imports.js +33 -13
- package/src/transformers/remove-ivy-jit-support-calls.js +23 -4
- package/src/transformers/replace_resources.d.ts +0 -1
- package/src/transformers/replace_resources.js +21 -61
- package/src/transformers/spec_helpers.js +22 -3
- package/src/webpack-diagnostics.d.ts +1 -1
- package/src/webpack-diagnostics.js +2 -3
- package/src/transformers/interfaces.d.ts +0 -34
- package/src/transformers/interfaces.js +0 -45
package/README.md
CHANGED
|
@@ -37,4 +37,4 @@ The loader works with webpack plugin to compile the application's TypeScript. It
|
|
|
37
37
|
- `jitMode` [default: `false`] - Enables JIT compilation and do not refactor the code to bootstrap. This replaces `templateUrl: "string"` with `template: require("string")` (and similar for styles) to allow for webpack to properly link the resources.
|
|
38
38
|
- `directTemplateLoading` [default: `true`] - Causes the plugin to load component templates (HTML) directly from the filesystem. This is more efficient if only using the `raw-loader` to load component templates. Do not enable this option if additional loaders are configured for component templates.
|
|
39
39
|
- `fileReplacements` [default: none] - Allows replacing TypeScript files with other TypeScript files in the build. This option acts on fully resolved file paths.
|
|
40
|
-
- `
|
|
40
|
+
- `inlineStyleFileExtension` [default: none] - When set inline component styles will be processed by Webpack as files with the provided extension.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngtools/webpack",
|
|
3
|
-
"version": "12.1.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "Webpack plugin that AoT compiles your Angular components and modules.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"enhanced-resolve": "5.8.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@angular/compiler-cli": "^12.0.0-next",
|
|
32
|
-
"typescript": "~4.2.3",
|
|
31
|
+
"@angular/compiler-cli": "^12.0.0 || ^12.1.0-next",
|
|
32
|
+
"typescript": "~4.2.3 || ~4.3.2",
|
|
33
33
|
"webpack": "^5.30.0"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
|
-
"node": "^12.14.1 ||
|
|
36
|
+
"node": "^12.14.1 || >=14.0.0",
|
|
37
37
|
"npm": "^6.11.0 || ^7.5.6",
|
|
38
38
|
"yarn": ">= 1.13.0"
|
|
39
39
|
}
|
package/src/index.js
CHANGED
|
@@ -6,13 +6,35 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
9
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
32
|
exports.ivy = exports.default = exports.AngularWebpackPlugin = exports.AngularWebpackLoaderPath = void 0;
|
|
11
|
-
const ivyInternal = require("./ivy");
|
|
33
|
+
const ivyInternal = __importStar(require("./ivy"));
|
|
12
34
|
var ivy_1 = require("./ivy");
|
|
13
35
|
Object.defineProperty(exports, "AngularWebpackLoaderPath", { enumerable: true, get: function () { return ivy_1.AngularWebpackLoaderPath; } });
|
|
14
36
|
Object.defineProperty(exports, "AngularWebpackPlugin", { enumerable: true, get: function () { return ivy_1.AngularWebpackPlugin; } });
|
|
15
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return ivy_1.default; } });
|
|
37
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(ivy_1).default; } });
|
|
16
38
|
/** @deprecated Deprecated as of v12, please use the direct exports
|
|
17
39
|
* (`AngularWebpackPlugin` instead of `ivy.AngularWebpackPlugin`)
|
|
18
40
|
*/
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { Compilation, LoaderContext } from 'webpack';
|
|
8
|
+
import type { Compilation, LoaderContext } from 'webpack';
|
|
9
9
|
export declare const InlineAngularResourceSymbol: unique symbol;
|
|
10
10
|
export interface CompilationWithInlineAngularResource extends Compilation {
|
|
11
11
|
[InlineAngularResourceSymbol]: string;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.InlineAngularResourceSymbol = void 0;
|
|
11
|
-
exports.InlineAngularResourceSymbol = Symbol();
|
|
11
|
+
exports.InlineAngularResourceSymbol = Symbol('@ngtools/webpack[angular-resource]');
|
|
12
12
|
function default_1() {
|
|
13
13
|
const callback = this.async();
|
|
14
14
|
const { data } = this.getOptions();
|
package/src/ivy/host.js
CHANGED
|
@@ -6,12 +6,30 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.augmentHostWithCaching = exports.augmentProgramWithVersioning = exports.augmentHostWithVersioning = exports.augmentHostWithSubstitutions = exports.augmentHostWithReplacements = exports.augmentHostWithNgcc = exports.augmentHostWithDependencyCollection = exports.augmentHostWithResources = void 0;
|
|
11
30
|
const crypto_1 = require("crypto");
|
|
12
|
-
const path = require("path");
|
|
13
|
-
const ts = require("typescript");
|
|
14
|
-
const transformers_1 = require("../transformers");
|
|
31
|
+
const path = __importStar(require("path"));
|
|
32
|
+
const ts = __importStar(require("typescript"));
|
|
15
33
|
const paths_1 = require("./paths");
|
|
16
34
|
function augmentHostWithResources(host, resourceLoader, options = {}) {
|
|
17
35
|
const resourceHost = host;
|
|
@@ -229,10 +247,6 @@ function augmentHostWithCaching(host, cache) {
|
|
|
229
247
|
}
|
|
230
248
|
const file = baseGetSourceFile.call(host, fileName, languageVersion, onError, true, ...parameters);
|
|
231
249
|
if (file) {
|
|
232
|
-
// Temporary workaround for upstream transform resource defect
|
|
233
|
-
if (file && !file.isDeclarationFile && file.text.includes('@Component')) {
|
|
234
|
-
transformers_1.workaroundStylePreprocessing(file);
|
|
235
|
-
}
|
|
236
250
|
cache.set(fileName, file);
|
|
237
251
|
}
|
|
238
252
|
return file;
|
package/src/ivy/loader.d.ts
CHANGED
|
@@ -5,5 +5,8 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import { AngularPluginSymbol, FileEmitterCollection } from './symbol';
|
|
9
|
+
export declare function angularWebpackLoader(this: import('webpack').LoaderContext<unknown> & {
|
|
10
|
+
[AngularPluginSymbol]?: FileEmitterCollection;
|
|
11
|
+
}, content: string, map: string): void;
|
|
9
12
|
export { angularWebpackLoader as default };
|
package/src/ivy/loader.js
CHANGED
|
@@ -6,20 +6,36 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.default = exports.angularWebpackLoader = void 0;
|
|
11
|
-
const path = require("path");
|
|
30
|
+
const path = __importStar(require("path"));
|
|
12
31
|
const symbol_1 = require("./symbol");
|
|
13
|
-
function angularWebpackLoader(content,
|
|
14
|
-
// Source map types are broken in the webpack type definitions
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
map) {
|
|
32
|
+
function angularWebpackLoader(content, map) {
|
|
17
33
|
const callback = this.async();
|
|
18
34
|
if (!callback) {
|
|
19
35
|
throw new Error('Invalid webpack version');
|
|
20
36
|
}
|
|
21
|
-
const fileEmitter = this
|
|
22
|
-
if (typeof fileEmitter !== 'object') {
|
|
37
|
+
const fileEmitter = this[symbol_1.AngularPluginSymbol];
|
|
38
|
+
if (!fileEmitter || typeof fileEmitter !== 'object') {
|
|
23
39
|
if (this.resourcePath.endsWith('.js')) {
|
|
24
40
|
// Passthrough for JS files when no plugin is used
|
|
25
41
|
this.callback(undefined, content, map);
|
package/src/ivy/paths.js
CHANGED
|
@@ -6,9 +6,28 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.externalizePath = exports.normalizePath = void 0;
|
|
11
|
-
const nodePath = require("path");
|
|
30
|
+
const nodePath = __importStar(require("path"));
|
|
12
31
|
const normalizationCache = new Map();
|
|
13
32
|
function normalizePath(path) {
|
|
14
33
|
let result = normalizationCache.get(path);
|
package/src/ivy/plugin.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { CompilerOptions } from '@angular/compiler-cli';
|
|
9
|
-
import { Compiler } from 'webpack';
|
|
9
|
+
import type { Compiler } from 'webpack';
|
|
10
10
|
export interface AngularWebpackPluginOptions {
|
|
11
11
|
tsconfig: string;
|
|
12
12
|
compilerOptions?: CompilerOptions;
|
|
@@ -16,6 +16,7 @@ export interface AngularWebpackPluginOptions {
|
|
|
16
16
|
emitClassMetadata: boolean;
|
|
17
17
|
emitNgModuleScope: boolean;
|
|
18
18
|
jitMode: boolean;
|
|
19
|
+
/** @deprecated use `inlineStyleFileExtension` instead. */
|
|
19
20
|
inlineStyleMimeType?: string;
|
|
20
21
|
inlineStyleFileExtension?: string;
|
|
21
22
|
}
|
|
@@ -32,6 +33,7 @@ export declare class AngularWebpackPlugin {
|
|
|
32
33
|
constructor(options?: Partial<AngularWebpackPluginOptions>);
|
|
33
34
|
get options(): AngularWebpackPluginOptions;
|
|
34
35
|
apply(compiler: Compiler): void;
|
|
36
|
+
private registerWithCompilation;
|
|
35
37
|
private markResourceUsed;
|
|
36
38
|
private rebuildRequiredFiles;
|
|
37
39
|
private loadConfiguration;
|
package/src/ivy/plugin.js
CHANGED
|
@@ -6,13 +6,31 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.AngularWebpackPlugin = void 0;
|
|
11
30
|
const compiler_cli_1 = require("@angular/compiler-cli");
|
|
12
31
|
const program_1 = require("@angular/compiler-cli/src/ngtsc/program");
|
|
13
32
|
const crypto_1 = require("crypto");
|
|
14
|
-
const ts = require("typescript");
|
|
15
|
-
const webpack_1 = require("webpack");
|
|
33
|
+
const ts = __importStar(require("typescript"));
|
|
16
34
|
const ngcc_processor_1 = require("../ngcc_processor");
|
|
17
35
|
const paths_plugin_1 = require("../paths-plugin");
|
|
18
36
|
const resource_loader_1 = require("../resource_loader");
|
|
@@ -31,18 +49,25 @@ const transformation_1 = require("./transformation");
|
|
|
31
49
|
*/
|
|
32
50
|
const DIAGNOSTICS_AFFECTED_THRESHOLD = 1;
|
|
33
51
|
function initializeNgccProcessor(compiler, tsconfig) {
|
|
34
|
-
var _a, _b, _c
|
|
52
|
+
var _a, _b, _c;
|
|
35
53
|
const { inputFileSystem, options: webpackOptions } = compiler;
|
|
36
54
|
const mainFields = (_c = (_b = (_a = webpackOptions.resolve) === null || _a === void 0 ? void 0 : _a.mainFields) === null || _b === void 0 ? void 0 : _b.flat()) !== null && _c !== void 0 ? _c : [];
|
|
37
55
|
const errors = [];
|
|
38
56
|
const warnings = [];
|
|
39
|
-
const
|
|
57
|
+
const resolver = compiler.resolverFactory.get('normal', {
|
|
58
|
+
// Caching must be disabled because it causes the resolver to become async after a rebuild
|
|
59
|
+
cache: false,
|
|
60
|
+
extensions: ['.json'],
|
|
61
|
+
useSyncFileSystemCalls: true,
|
|
62
|
+
});
|
|
63
|
+
const processor = new ngcc_processor_1.NgccProcessor(mainFields, warnings, errors, compiler.context, tsconfig, inputFileSystem, resolver);
|
|
40
64
|
return { processor, errors, warnings };
|
|
41
65
|
}
|
|
42
66
|
function hashContent(content) {
|
|
43
67
|
return crypto_1.createHash('md5').update(content).digest();
|
|
44
68
|
}
|
|
45
69
|
const PLUGIN_NAME = 'angular-compiler';
|
|
70
|
+
const compilationFileEmitters = new WeakMap();
|
|
46
71
|
class AngularWebpackPlugin {
|
|
47
72
|
constructor(options = {}) {
|
|
48
73
|
this.fileDependencies = new Map();
|
|
@@ -64,13 +89,14 @@ class AngularWebpackPlugin {
|
|
|
64
89
|
return this.pluginOptions;
|
|
65
90
|
}
|
|
66
91
|
apply(compiler) {
|
|
92
|
+
const { NormalModuleReplacementPlugin, util } = compiler.webpack;
|
|
67
93
|
// Setup file replacements with webpack
|
|
68
94
|
for (const [key, value] of Object.entries(this.pluginOptions.fileReplacements)) {
|
|
69
|
-
new
|
|
95
|
+
new NormalModuleReplacementPlugin(new RegExp('^' + key.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&') + '$'), value).apply(compiler);
|
|
70
96
|
}
|
|
71
97
|
// Set resolver options
|
|
72
98
|
const pathsPlugin = new paths_plugin_1.TypeScriptPathsPlugin();
|
|
73
|
-
compiler.hooks.afterResolvers.tap(
|
|
99
|
+
compiler.hooks.afterResolvers.tap(PLUGIN_NAME, (compiler) => {
|
|
74
100
|
// When Ivy is enabled we need to add the fields added by NGCC
|
|
75
101
|
// to take precedence over the provided mainFields.
|
|
76
102
|
// NGCC adds fields in package.json suffixed with '_ivy_ngcc'
|
|
@@ -84,22 +110,16 @@ class AngularWebpackPlugin {
|
|
|
84
110
|
(_b = resolveOptions.plugins) !== null && _b !== void 0 ? _b : (resolveOptions.plugins = []);
|
|
85
111
|
resolveOptions.plugins.push(pathsPlugin);
|
|
86
112
|
// https://github.com/webpack/webpack/issues/11635#issuecomment-707016779
|
|
87
|
-
return
|
|
113
|
+
return util.cleverMerge(resolveOptions, { mainFields: [...ivyMainFields, '...'] });
|
|
88
114
|
});
|
|
89
115
|
});
|
|
90
116
|
let ngccProcessor;
|
|
91
117
|
let resourceLoader;
|
|
92
118
|
let previousUnused;
|
|
93
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (
|
|
94
|
-
var _a;
|
|
95
|
-
const compilation = thisCompilation;
|
|
119
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
96
120
|
// Register plugin to ensure deterministic emit order in multi-plugin usage
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
const emitRegistration = compilation[symbol_1.AngularPluginSymbol].register();
|
|
101
|
-
// Store watch mode; assume true if not present (webpack < 4.23.0)
|
|
102
|
-
this.watchMode = (_a = compiler.watchMode) !== null && _a !== void 0 ? _a : true;
|
|
121
|
+
const emitRegistration = this.registerWithCompilation(compilation);
|
|
122
|
+
this.watchMode = compiler.watchMode;
|
|
103
123
|
// Initialize the resource loader if not already setup
|
|
104
124
|
if (!resourceLoader) {
|
|
105
125
|
resourceLoader = new resource_loader_1.WebpackResourceLoader(this.watchMode);
|
|
@@ -113,7 +133,7 @@ class AngularWebpackPlugin {
|
|
|
113
133
|
ngccProcessor = processor;
|
|
114
134
|
}
|
|
115
135
|
// Setup and read TypeScript and Angular compiler configuration
|
|
116
|
-
const { compilerOptions, rootNames, errors } = this.loadConfiguration(
|
|
136
|
+
const { compilerOptions, rootNames, errors } = this.loadConfiguration();
|
|
117
137
|
// Create diagnostics reporter and report configuration file errors
|
|
118
138
|
const diagnosticsReporter = diagnostics_1.createDiagnosticsReporter(compilation);
|
|
119
139
|
diagnosticsReporter(errors);
|
|
@@ -172,8 +192,9 @@ class AngularWebpackPlugin {
|
|
|
172
192
|
if (internalFiles === null || internalFiles === void 0 ? void 0 : internalFiles.has(sourceFile)) {
|
|
173
193
|
continue;
|
|
174
194
|
}
|
|
175
|
-
// Ensure all program files are considered part of the compilation and will be watched
|
|
176
|
-
|
|
195
|
+
// Ensure all program files are considered part of the compilation and will be watched.
|
|
196
|
+
// Webpack does not normalize paths. Therefore, we need to normalize the path with FS seperators.
|
|
197
|
+
compilation.fileDependencies.add(paths_1.externalizePath(sourceFile.fileName));
|
|
177
198
|
// Add all non-declaration files to the initial set of unused files. The set will be
|
|
178
199
|
// analyzed and pruned after all Webpack modules are finished building.
|
|
179
200
|
if (!sourceFile.isDeclarationFile) {
|
|
@@ -208,6 +229,18 @@ class AngularWebpackPlugin {
|
|
|
208
229
|
emitRegistration.update(fileEmitter);
|
|
209
230
|
});
|
|
210
231
|
}
|
|
232
|
+
registerWithCompilation(compilation) {
|
|
233
|
+
let fileEmitters = compilationFileEmitters.get(compilation);
|
|
234
|
+
if (!fileEmitters) {
|
|
235
|
+
fileEmitters = new symbol_1.FileEmitterCollection();
|
|
236
|
+
compilationFileEmitters.set(compilation, fileEmitters);
|
|
237
|
+
compilation.compiler.webpack.NormalModule.getCompilationHooks(compilation).loader.tap(PLUGIN_NAME, (loaderContext) => {
|
|
238
|
+
loaderContext[symbol_1.AngularPluginSymbol] = fileEmitters;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const emitRegistration = fileEmitters.register();
|
|
242
|
+
return emitRegistration;
|
|
243
|
+
}
|
|
211
244
|
markResourceUsed(normalizedResourcePath, currentUnused) {
|
|
212
245
|
if (!currentUnused.has(normalizedResourcePath)) {
|
|
213
246
|
return;
|
|
@@ -258,7 +291,7 @@ class AngularWebpackPlugin {
|
|
|
258
291
|
this.requiredFilesToEmit.clear();
|
|
259
292
|
this.requiredFilesToEmitCache.clear();
|
|
260
293
|
}
|
|
261
|
-
loadConfiguration(
|
|
294
|
+
loadConfiguration() {
|
|
262
295
|
const { options: compilerOptions, rootNames, errors, } = compiler_cli_1.readConfiguration(this.pluginOptions.tsconfig, this.pluginOptions.compilerOptions);
|
|
263
296
|
compilerOptions.enableIvy = true;
|
|
264
297
|
compilerOptions.noEmitOnError = false;
|
package/src/ivy/symbol.js
CHANGED
|
@@ -6,53 +6,51 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return value;
|
|
9
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
10
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
11
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
12
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
13
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
14
|
};
|
|
16
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
17
|
-
if (!
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return privateMap.get(receiver);
|
|
15
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
16
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
17
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
18
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
19
|
};
|
|
22
|
-
var
|
|
20
|
+
var _FileEmitterRegistration_fileEmitter, _FileEmitterCollection_registrations;
|
|
23
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
22
|
exports.FileEmitterCollection = exports.FileEmitterRegistration = exports.AngularPluginSymbol = void 0;
|
|
25
|
-
exports.AngularPluginSymbol = Symbol.for('@
|
|
23
|
+
exports.AngularPluginSymbol = Symbol.for('@ngtools/webpack[angular-compiler]');
|
|
26
24
|
class FileEmitterRegistration {
|
|
27
25
|
constructor() {
|
|
28
|
-
|
|
26
|
+
_FileEmitterRegistration_fileEmitter.set(this, void 0);
|
|
29
27
|
}
|
|
30
28
|
update(emitter) {
|
|
31
|
-
__classPrivateFieldSet(this,
|
|
29
|
+
__classPrivateFieldSet(this, _FileEmitterRegistration_fileEmitter, emitter, "f");
|
|
32
30
|
}
|
|
33
31
|
emit(file) {
|
|
34
|
-
if (!__classPrivateFieldGet(this,
|
|
32
|
+
if (!__classPrivateFieldGet(this, _FileEmitterRegistration_fileEmitter, "f")) {
|
|
35
33
|
throw new Error('Emit attempted before Angular Webpack plugin initialization.');
|
|
36
34
|
}
|
|
37
|
-
return __classPrivateFieldGet(this,
|
|
35
|
+
return __classPrivateFieldGet(this, _FileEmitterRegistration_fileEmitter, "f").call(this, file);
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
exports.FileEmitterRegistration = FileEmitterRegistration;
|
|
41
|
-
|
|
39
|
+
_FileEmitterRegistration_fileEmitter = new WeakMap();
|
|
42
40
|
class FileEmitterCollection {
|
|
43
41
|
constructor() {
|
|
44
|
-
|
|
42
|
+
_FileEmitterCollection_registrations.set(this, []);
|
|
45
43
|
}
|
|
46
44
|
register() {
|
|
47
45
|
const registration = new FileEmitterRegistration();
|
|
48
|
-
__classPrivateFieldGet(this,
|
|
46
|
+
__classPrivateFieldGet(this, _FileEmitterCollection_registrations, "f").push(registration);
|
|
49
47
|
return registration;
|
|
50
48
|
}
|
|
51
49
|
async emit(file) {
|
|
52
|
-
if (__classPrivateFieldGet(this,
|
|
53
|
-
return __classPrivateFieldGet(this,
|
|
50
|
+
if (__classPrivateFieldGet(this, _FileEmitterCollection_registrations, "f").length === 1) {
|
|
51
|
+
return __classPrivateFieldGet(this, _FileEmitterCollection_registrations, "f")[0].emit(file);
|
|
54
52
|
}
|
|
55
|
-
for (const registration of __classPrivateFieldGet(this,
|
|
53
|
+
for (const registration of __classPrivateFieldGet(this, _FileEmitterCollection_registrations, "f")) {
|
|
56
54
|
const result = await registration.emit(file);
|
|
57
55
|
if (result) {
|
|
58
56
|
return result;
|
|
@@ -61,4 +59,4 @@ class FileEmitterCollection {
|
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
exports.FileEmitterCollection = FileEmitterCollection;
|
|
64
|
-
|
|
62
|
+
_FileEmitterCollection_registrations = new WeakMap();
|
package/src/ivy/system.js
CHANGED
|
@@ -6,9 +6,28 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.createWebpackSystem = void 0;
|
|
11
|
-
const ts = require("typescript");
|
|
30
|
+
const ts = __importStar(require("typescript"));
|
|
12
31
|
const paths_1 = require("./paths");
|
|
13
32
|
function shouldNotWrite() {
|
|
14
33
|
throw new Error('Webpack TypeScript System should not write.');
|
|
@@ -6,10 +6,29 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.replaceBootstrap = exports.mergeTransformers = exports.createJitTransformers = exports.createAotTransformers = void 0;
|
|
11
30
|
const compiler_cli_1 = require("@angular/compiler-cli");
|
|
12
|
-
const ts = require("typescript");
|
|
31
|
+
const ts = __importStar(require("typescript"));
|
|
13
32
|
const elide_imports_1 = require("../transformers/elide_imports");
|
|
14
33
|
const remove_ivy_jit_support_calls_1 = require("../transformers/remove-ivy-jit-support-calls");
|
|
15
34
|
const replace_resources_1 = require("../transformers/replace_resources");
|
|
@@ -79,9 +98,9 @@ function replaceBootstrap(getTypeChecker) {
|
|
|
79
98
|
let updatedSourceFile = ts.visitEachChild(sourceFile, visitNode, context);
|
|
80
99
|
if (bootstrapImport) {
|
|
81
100
|
// Remove any unused platform browser dynamic imports
|
|
82
|
-
const removals = elide_imports_1.elideImports(updatedSourceFile, replacedNodes, getTypeChecker, context.getCompilerOptions())
|
|
83
|
-
if (removals.
|
|
84
|
-
updatedSourceFile = ts.visitEachChild(updatedSourceFile, (node) => (removals.
|
|
101
|
+
const removals = elide_imports_1.elideImports(updatedSourceFile, replacedNodes, getTypeChecker, context.getCompilerOptions());
|
|
102
|
+
if (removals.size > 0) {
|
|
103
|
+
updatedSourceFile = ts.visitEachChild(updatedSourceFile, (node) => (removals.has(node) ? undefined : node), context);
|
|
85
104
|
}
|
|
86
105
|
// Add new platform browser import
|
|
87
106
|
return nodeFactory.updateSourceFile(updatedSourceFile, ts.setTextRange(nodeFactory.createNodeArray([bootstrapImport, ...updatedSourceFile.statements]), sourceFile.statements));
|
package/src/ngcc_processor.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
+
import { Resolver } from 'enhanced-resolve';
|
|
8
9
|
import * as ts from 'typescript';
|
|
9
10
|
import { InputFileSystem } from './ivy/system';
|
|
10
11
|
export declare class NgccProcessor {
|
|
@@ -14,12 +15,11 @@ export declare class NgccProcessor {
|
|
|
14
15
|
private readonly basePath;
|
|
15
16
|
private readonly tsConfigPath;
|
|
16
17
|
private readonly inputFileSystem;
|
|
17
|
-
private readonly
|
|
18
|
+
private readonly resolver;
|
|
18
19
|
private _processedModules;
|
|
19
20
|
private _logger;
|
|
20
21
|
private _nodeModulesDirectory;
|
|
21
|
-
|
|
22
|
-
constructor(propertiesToConsider: string[], compilationWarnings: (Error | string)[], compilationErrors: (Error | string)[], basePath: string, tsConfigPath: string, inputFileSystem: InputFileSystem, symlinks: boolean | undefined);
|
|
22
|
+
constructor(propertiesToConsider: string[], compilationWarnings: (Error | string)[], compilationErrors: (Error | string)[], basePath: string, tsConfigPath: string, inputFileSystem: InputFileSystem, resolver: Resolver);
|
|
23
23
|
/** Process the entire node modules tree. */
|
|
24
24
|
process(): void;
|
|
25
25
|
/** Process a module and it's depedencies. */
|