@ngtools/webpack 13.1.0-next.2 → 13.1.0-next.3

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": "13.1.0-next.2",
3
+ "version": "13.1.0-next.3",
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",
@@ -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
+ import { LoaderContext } from 'webpack';
8
9
  export declare const DirectAngularResourceLoaderPath: string;
9
- export default function (content: string): string;
10
+ export default function (this: LoaderContext<{
11
+ esModule?: 'true' | 'false';
12
+ }>, content: string): string;
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.DirectAngularResourceLoaderPath = void 0;
11
11
  exports.DirectAngularResourceLoaderPath = __filename;
12
12
  function default_1(content) {
13
- return `export default ${JSON.stringify(content)};`;
13
+ const { esModule } = this.getOptions();
14
+ return `${esModule === 'false' ? 'module.exports =' : 'export default'} ${JSON.stringify(content)};`;
14
15
  }
15
16
  exports.default = default_1;
@@ -88,7 +88,7 @@ function visitDecorator(nodeFactory, node, typeChecker, directTemplateLoading, r
88
88
  }
89
89
  return nodeFactory.updateDecorator(node, nodeFactory.updateCallExpression(decoratorFactory, decoratorFactory.expression, decoratorFactory.typeArguments, [nodeFactory.updateObjectLiteralExpression(objectExpression, properties)]));
90
90
  }
91
- function visitComponentMetadata(nodeFactory, node, styleReplacements, directTemplateLoading, resourceImportDeclarations, moduleKind, inlineStyleFileExtension) {
91
+ function visitComponentMetadata(nodeFactory, node, styleReplacements, directTemplateLoading, resourceImportDeclarations, moduleKind = ts.ModuleKind.ES2015, inlineStyleFileExtension) {
92
92
  if (!ts.isPropertyAssignment(node) || ts.isComputedPropertyName(node.name)) {
93
93
  return node;
94
94
  }
@@ -97,7 +97,8 @@ function visitComponentMetadata(nodeFactory, node, styleReplacements, directTemp
97
97
  case 'moduleId':
98
98
  return undefined;
99
99
  case 'templateUrl':
100
- const url = getResourceUrl(node.initializer, directTemplateLoading ? `!${direct_resource_1.DirectAngularResourceLoaderPath}!` : '');
100
+ const loaderOptions = moduleKind < ts.ModuleKind.ES2015 ? '?esModule=false' : '';
101
+ const url = getResourceUrl(node.initializer, directTemplateLoading ? `!${direct_resource_1.DirectAngularResourceLoaderPath}${loaderOptions}!` : '');
101
102
  if (!url) {
102
103
  return node;
103
104
  }
@@ -165,10 +166,10 @@ function isComponentDecorator(node, typeChecker) {
165
166
  }
166
167
  return false;
167
168
  }
168
- function createResourceImport(nodeFactory, url, resourceImportDeclarations, moduleKind = ts.ModuleKind.ES2015) {
169
+ function createResourceImport(nodeFactory, url, resourceImportDeclarations, moduleKind) {
169
170
  const urlLiteral = nodeFactory.createStringLiteral(url);
170
171
  if (moduleKind < ts.ModuleKind.ES2015) {
171
- return nodeFactory.createPropertyAccessExpression(nodeFactory.createCallExpression(nodeFactory.createIdentifier('require'), [], [urlLiteral]), 'default');
172
+ return nodeFactory.createCallExpression(nodeFactory.createIdentifier('require'), [], [urlLiteral]);
172
173
  }
173
174
  else {
174
175
  const importName = nodeFactory.createIdentifier(`__NG_CLI_RESOURCE__${resourceImportDeclarations.length}`);