@ngtools/webpack 11.1.0-next.3 → 11.1.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngtools/webpack",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.1",
|
|
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",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/angular/angular-cli",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@angular-devkit/core": "11.1.
|
|
29
|
-
"enhanced-resolve": "5.
|
|
28
|
+
"@angular-devkit/core": "11.1.1",
|
|
29
|
+
"enhanced-resolve": "5.6.0",
|
|
30
30
|
"webpack-sources": "2.2.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
package/src/ivy/plugin.js
CHANGED
|
@@ -272,7 +272,18 @@ class AngularWebpackPlugin {
|
|
|
272
272
|
for (const sourceFile of builder.getSourceFiles()) {
|
|
273
273
|
// Collect Angular template diagnostics
|
|
274
274
|
if (!ignoreForDiagnostics.has(sourceFile)) {
|
|
275
|
-
|
|
275
|
+
// The below check should be removed once support for compiler 11.0 is dropped.
|
|
276
|
+
// Also, the below require should be changed to an ES6 import.
|
|
277
|
+
if (angularCompiler.getDiagnosticsForFile) {
|
|
278
|
+
// @angular/compiler-cli 11.1+
|
|
279
|
+
const { OptimizeFor } = require('@angular/compiler-cli/src/ngtsc/typecheck/api');
|
|
280
|
+
diagnosticsReporter(angularCompiler.getDiagnosticsForFile(sourceFile, OptimizeFor.WholeProgram));
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
// @angular/compiler-cli 11.0+
|
|
284
|
+
const getDiagnostics = angularCompiler.getDiagnostics;
|
|
285
|
+
diagnosticsReporter(getDiagnostics.call(angularCompiler, sourceFile));
|
|
286
|
+
}
|
|
276
287
|
}
|
|
277
288
|
// Collect sources that are required to be emitted
|
|
278
289
|
if (!sourceFile.isDeclarationFile &&
|
|
@@ -23,7 +23,7 @@ function createAotTransformers(builder, options) {
|
|
|
23
23
|
const removeNgModuleScope = !options.emitNgModuleScope;
|
|
24
24
|
if (removeClassMetadata || removeNgModuleScope) {
|
|
25
25
|
// tslint:disable-next-line: no-non-null-assertion
|
|
26
|
-
transformers.
|
|
26
|
+
transformers.before.push(remove_ivy_jit_support_calls_1.removeIvyJitSupportCalls(removeClassMetadata, removeNgModuleScope, getTypeChecker));
|
|
27
27
|
}
|
|
28
28
|
return transformers;
|
|
29
29
|
}
|
|
@@ -102,6 +102,10 @@ function elideImports(sourceFile, removedNodes, getTypeChecker, compilerOptions)
|
|
|
102
102
|
return [];
|
|
103
103
|
}
|
|
104
104
|
const isUnused = (node) => {
|
|
105
|
+
// Do not remove JSX factory imports
|
|
106
|
+
if (node.text === compilerOptions.jsxFactory) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
105
109
|
const symbol = typeChecker.getSymbolAtLocation(node);
|
|
106
110
|
return symbol && !usedSymbols.has(symbol);
|
|
107
111
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
2
|
import { WebpackCompilerHost } from '../compiler_host';
|
|
3
|
-
export declare function createTypescriptContext(content: string, additionalFiles?: Record<string, string>, useLibs?: boolean, extraCompilerOptions?: ts.CompilerOptions): {
|
|
3
|
+
export declare function createTypescriptContext(content: string, additionalFiles?: Record<string, string>, useLibs?: boolean, extraCompilerOptions?: ts.CompilerOptions, jsxFile?: boolean): {
|
|
4
4
|
compilerHost: WebpackCompilerHost;
|
|
5
5
|
program: ts.Program;
|
|
6
6
|
};
|
|
@@ -15,10 +15,11 @@ const ts = require("typescript");
|
|
|
15
15
|
const compiler_host_1 = require("../compiler_host");
|
|
16
16
|
// Test transform helpers.
|
|
17
17
|
const basePath = '/project/src/';
|
|
18
|
-
const
|
|
18
|
+
const basefileName = basePath + 'test-file.ts';
|
|
19
19
|
const typeScriptLibFiles = loadTypeScriptLibFiles();
|
|
20
20
|
const tsLibFiles = loadTsLibFiles();
|
|
21
|
-
function createTypescriptContext(content, additionalFiles, useLibs = false, extraCompilerOptions = {}) {
|
|
21
|
+
function createTypescriptContext(content, additionalFiles, useLibs = false, extraCompilerOptions = {}, jsxFile = false) {
|
|
22
|
+
const fileName = basefileName + (jsxFile ? 'x' : '');
|
|
22
23
|
// Set compiler options.
|
|
23
24
|
const compilerOptions = {
|
|
24
25
|
noEmitOnError: useLibs,
|
|
@@ -81,7 +82,7 @@ function transformTypescript(content, transformers, program, compilerHost) {
|
|
|
81
82
|
throw new Error(ts.formatDiagnostics(diagnostics, compilerHost));
|
|
82
83
|
}
|
|
83
84
|
// Return the transpiled js.
|
|
84
|
-
return compilerHost.readFile(
|
|
85
|
+
return compilerHost.readFile(basefileName.replace(/\.tsx?$/, '.js'));
|
|
85
86
|
}
|
|
86
87
|
exports.transformTypescript = transformTypescript;
|
|
87
88
|
function loadTypeScriptLibFiles() {
|