@ngtools/webpack 12.1.0-next.6 → 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 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
- - `inlineStyleMimeType` [default: none] - When set to a valid MIME type, enables conversion of an Angular Component's inline styles into data URIs. This allows a Webpack 5 configuration rule to use the `mimetype` condition to process the inline styles. A valid MIME type is a string starting with `text/` (Example for CSS: `text/css`).
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-next.6",
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",
package/src/ivy/host.js CHANGED
@@ -30,7 +30,6 @@ exports.augmentHostWithCaching = exports.augmentProgramWithVersioning = exports.
30
30
  const crypto_1 = require("crypto");
31
31
  const path = __importStar(require("path"));
32
32
  const ts = __importStar(require("typescript"));
33
- const transformers_1 = require("../transformers");
34
33
  const paths_1 = require("./paths");
35
34
  function augmentHostWithResources(host, resourceLoader, options = {}) {
36
35
  const resourceHost = host;
@@ -248,10 +247,6 @@ function augmentHostWithCaching(host, cache) {
248
247
  }
249
248
  const file = baseGetSourceFile.call(host, fileName, languageVersion, onError, true, ...parameters);
250
249
  if (file) {
251
- // Temporary workaround for upstream transform resource defect
252
- if (file && !file.isDeclarationFile && file.text.includes('@Component')) {
253
- transformers_1.workaroundStylePreprocessing(file);
254
- }
255
250
  cache.set(fileName, file);
256
251
  }
257
252
  return file;
@@ -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
  }
@@ -8,4 +8,3 @@
8
8
  import * as ts from 'typescript';
9
9
  export declare function replaceResources(shouldTransform: (fileName: string) => boolean, getTypeChecker: () => ts.TypeChecker, directTemplateLoading?: boolean, inlineStyleMimeType?: string, inlineStyleFileExtension?: string): ts.TransformerFactory<ts.SourceFile>;
10
10
  export declare function getResourceUrl(node: ts.Node, loader?: string): string | null;
11
- export declare function workaroundStylePreprocessing(sourceFile: ts.SourceFile): void;
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  return result;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.workaroundStylePreprocessing = exports.getResourceUrl = exports.replaceResources = void 0;
29
+ exports.getResourceUrl = exports.replaceResources = void 0;
30
30
  const ts = __importStar(require("typescript"));
31
31
  const inlineDataLoaderPath = require.resolve('../inline-data-loader');
32
32
  function replaceResources(shouldTransform, getTypeChecker, directTemplateLoading = false, inlineStyleMimeType, inlineStyleFileExtension) {
@@ -222,62 +222,3 @@ function getDecoratorOrigin(decorator, typeChecker) {
222
222
  }
223
223
  return null;
224
224
  }
225
- function workaroundStylePreprocessing(sourceFile) {
226
- const visitNode = (node) => {
227
- var _a;
228
- if (ts.isClassDeclaration(node) && ((_a = node.decorators) === null || _a === void 0 ? void 0 : _a.length)) {
229
- for (const decorator of node.decorators) {
230
- visitDecoratorWorkaround(decorator);
231
- }
232
- }
233
- return ts.forEachChild(node, visitNode);
234
- };
235
- ts.forEachChild(sourceFile, visitNode);
236
- }
237
- exports.workaroundStylePreprocessing = workaroundStylePreprocessing;
238
- function visitDecoratorWorkaround(node) {
239
- if (!ts.isCallExpression(node.expression)) {
240
- return;
241
- }
242
- const decoratorFactory = node.expression;
243
- if (!ts.isIdentifier(decoratorFactory.expression) ||
244
- decoratorFactory.expression.text !== 'Component') {
245
- return;
246
- }
247
- const args = decoratorFactory.arguments;
248
- if (args.length !== 1 || !ts.isObjectLiteralExpression(args[0])) {
249
- // Unsupported component metadata
250
- return;
251
- }
252
- const objectExpression = args[0];
253
- // check if a `styles` property is present
254
- let hasStyles = false;
255
- for (const element of objectExpression.properties) {
256
- if (!ts.isPropertyAssignment(element) || ts.isComputedPropertyName(element.name)) {
257
- continue;
258
- }
259
- if (element.name.text === 'styles') {
260
- hasStyles = true;
261
- break;
262
- }
263
- }
264
- if (hasStyles) {
265
- return;
266
- }
267
- const nodeFactory = ts.factory;
268
- // add a `styles` property to workaround upstream compiler defect
269
- const emptyArray = nodeFactory.createArrayLiteralExpression();
270
- const stylePropertyName = nodeFactory.createIdentifier('styles');
271
- const styleProperty = nodeFactory.createPropertyAssignment(stylePropertyName, emptyArray);
272
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
273
- stylePropertyName.parent = styleProperty;
274
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
275
- emptyArray.parent = styleProperty;
276
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
277
- styleProperty.parent = objectExpression;
278
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
279
- objectExpression.properties = nodeFactory.createNodeArray([
280
- ...objectExpression.properties,
281
- styleProperty,
282
- ]);
283
- }