8
8
9
9
import { tags } from '@angular-devkit/core' ;
10
10
import * as ts from 'typescript' ;
11
- import { DirectAngularResourceLoaderPath } from '../loaders/direct-resource' ;
12
11
import { replaceResources } from './replace_resources' ;
13
12
import { createTypescriptContext , transformTypescript } from './spec_helpers' ;
14
13
15
14
function transform (
16
15
input : string ,
17
16
shouldTransform = true ,
18
- directTemplateLoading = true ,
19
17
importHelpers = true ,
20
18
module : ts . ModuleKind = ts . ModuleKind . ES2020 ,
21
19
) {
@@ -24,11 +22,7 @@ function transform(
24
22
module,
25
23
} ) ;
26
24
const getTypeChecker = ( ) => program . getTypeChecker ( ) ;
27
- const transformer = replaceResources (
28
- ( ) => shouldTransform ,
29
- getTypeChecker ,
30
- directTemplateLoading ,
31
- ) ;
25
+ const transformer = replaceResources ( ( ) => shouldTransform , getTypeChecker ) ;
32
26
33
27
return transformTypescript ( input , [ transformer ] , program , compilerHost ) ;
34
28
}
@@ -51,9 +45,9 @@ describe('@ngtools/webpack transformers', () => {
51
45
` ;
52
46
const output = tags . stripIndent `
53
47
import { __decorate } from "tslib";
54
- import __NG_CLI_RESOURCE__0 from "! ${ DirectAngularResourceLoaderPath } ! ./app.component.html";
55
- import __NG_CLI_RESOURCE__1 from "./app.component.css";
56
- import __NG_CLI_RESOURCE__2 from "./app.component.2.css";
48
+ import __NG_CLI_RESOURCE__0 from "./app.component.html?ngResource ";
49
+ import __NG_CLI_RESOURCE__1 from "./app.component.css?ngResource ";
50
+ import __NG_CLI_RESOURCE__2 from "./app.component.2.css?ngResource ";
57
51
import { Component } from '@angular/core';
58
52
59
53
let AppComponent = class AppComponent {
@@ -102,53 +96,12 @@ describe('@ngtools/webpack transformers', () => {
102
96
AppComponent = (0, tslib_1.__decorate)([
103
97
(0, core_1.Component)({
104
98
selector: 'app-root',
105
- template: require("! ${ DirectAngularResourceLoaderPath } ?esModule=false! ./app.component.html"),
106
- styles: [require("./app.component.css"), require("./app.component.2.css")] }) ], AppComponent);
99
+ template: require("./app.component.html?ngResource "),
100
+ styles: [require("./app.component.css?ngResource "), require("./app.component.2.css?ngResource ")] }) ], AppComponent);
107
101
exports.AppComponent = AppComponent;
108
102
` ;
109
103
110
- const result = transform ( input , true , true , true , ts . ModuleKind . CommonJS ) ;
111
- expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
112
- } ) ;
113
-
114
- it ( 'should not replace resources when directTemplateLoading is false' , ( ) => {
115
- const input = tags . stripIndent `
116
- import { Component } from '@angular/core';
117
-
118
- @Component({
119
- selector: 'app-root',
120
- templateUrl: './app.component.html',
121
- styleUrls: [
122
- './app.component.css',
123
- './app.component.2.css'
124
- ]
125
- })
126
- export class AppComponent {
127
- title = 'app';
128
- }
129
- ` ;
130
- const output = tags . stripIndent `
131
- import { __decorate } from "tslib";
132
- import __NG_CLI_RESOURCE__0 from "./app.component.html";
133
- import __NG_CLI_RESOURCE__1 from "./app.component.css";
134
- import __NG_CLI_RESOURCE__2 from "./app.component.2.css";
135
- import { Component } from '@angular/core';
136
- let AppComponent = class AppComponent {
137
- constructor() {
138
- this.title = 'app';
139
- }
140
- };
141
- AppComponent = __decorate([
142
- Component({
143
- selector: 'app-root',
144
- template: __NG_CLI_RESOURCE__0,
145
- styles: [__NG_CLI_RESOURCE__1, __NG_CLI_RESOURCE__2]
146
- })
147
- ], AppComponent);
148
- export { AppComponent };
149
- ` ;
150
-
151
- const result = transform ( input , true , false ) ;
104
+ const result = transform ( input , true , true , ts . ModuleKind . CommonJS ) ;
152
105
expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
153
106
} ) ;
154
107
@@ -166,7 +119,7 @@ describe('@ngtools/webpack transformers', () => {
166
119
` ;
167
120
const output = tags . stripIndent `
168
121
import { __decorate } from "tslib";
169
- import __NG_CLI_RESOURCE__0 from "! ${ DirectAngularResourceLoaderPath } ! ./app.component.svg";
122
+ import __NG_CLI_RESOURCE__0 from "./app.component.svg?ngResource ";
170
123
import { Component } from '@angular/core';
171
124
let AppComponent = class AppComponent {
172
125
constructor() {
@@ -202,8 +155,8 @@ describe('@ngtools/webpack transformers', () => {
202
155
` ;
203
156
const output = tags . stripIndent `
204
157
import { __decorate } from "tslib";
205
- import __NG_CLI_RESOURCE__0 from "! ${ DirectAngularResourceLoaderPath } ! ./app.component.html";
206
- import __NG_CLI_RESOURCE__1 from "./app.component.css";
158
+ import __NG_CLI_RESOURCE__0 from "./app.component.html?ngResource ";
159
+ import __NG_CLI_RESOURCE__1 from "./app.component.css?ngResource ";
207
160
import { Component } from '@angular/core';
208
161
209
162
let AppComponent = class AppComponent {
@@ -240,9 +193,9 @@ describe('@ngtools/webpack transformers', () => {
240
193
` ;
241
194
const output = `
242
195
import { __decorate } from "tslib";
243
- import __NG_CLI_RESOURCE__0 from "! ${ DirectAngularResourceLoaderPath } ! ./app.component.html";
244
- import __NG_CLI_RESOURCE__1 from "./app.component.css";
245
- import __NG_CLI_RESOURCE__2 from "./app.component.2.css";
196
+ import __NG_CLI_RESOURCE__0 from "./app.component.html?ngResource ";
197
+ import __NG_CLI_RESOURCE__1 from "./app.component.css?ngResource ";
198
+ import __NG_CLI_RESOURCE__2 from "./app.component.2.css?ngResource ";
246
199
247
200
import { Component } from '@angular/core';
248
201
let AppComponent = class AppComponent {
@@ -279,9 +232,9 @@ describe('@ngtools/webpack transformers', () => {
279
232
` ;
280
233
const output = tags . stripIndent `
281
234
import { __decorate } from "tslib";
282
- import __NG_CLI_RESOURCE__0 from "! ${ DirectAngularResourceLoaderPath } ! ./app.component.html";
283
- import __NG_CLI_RESOURCE__1 from "./app.component.css";
284
- import __NG_CLI_RESOURCE__2 from "./app.component.2.css";
235
+ import __NG_CLI_RESOURCE__0 from "./app.component.html?ngResource ";
236
+ import __NG_CLI_RESOURCE__1 from "./app.component.css?ngResource ";
237
+ import __NG_CLI_RESOURCE__2 from "./app.component.2.css?ngResource ";
285
238
import { Component as NgComponent } from '@angular/core';
286
239
287
240
let AppComponent = class AppComponent {
@@ -301,7 +254,7 @@ describe('@ngtools/webpack transformers', () => {
301
254
302
255
const { program } = createTypescriptContext ( input ) ;
303
256
const getTypeChecker = ( ) => program . getTypeChecker ( ) ;
304
- const transformer = replaceResources ( ( ) => true , getTypeChecker , true ) ;
257
+ const transformer = replaceResources ( ( ) => true , getTypeChecker ) ;
305
258
const result = transformTypescript ( input , [ transformer ] ) ;
306
259
307
260
expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
@@ -322,9 +275,9 @@ describe('@ngtools/webpack transformers', () => {
322
275
` ;
323
276
const output = tags . stripIndent `
324
277
import { __decorate } from "tslib";
325
- import __NG_CLI_RESOURCE__0 from "! ${ DirectAngularResourceLoaderPath } ! ./app.component.html";
326
- import __NG_CLI_RESOURCE__1 from "./app.component.css";
327
- import __NG_CLI_RESOURCE__2 from "./app.component.2.css";
278
+ import __NG_CLI_RESOURCE__0 from "./app.component.html?ngResource ";
279
+ import __NG_CLI_RESOURCE__1 from "./app.component.css?ngResource ";
280
+ import __NG_CLI_RESOURCE__2 from "./app.component.2.css?ngResource ";
328
281
329
282
import * as ng from '@angular/core';
330
283
let AppComponent = class AppComponent {
@@ -367,8 +320,8 @@ describe('@ngtools/webpack transformers', () => {
367
320
368
321
const output = tags . stripIndent `
369
322
import { __decorate } from "tslib";
370
- import __NG_CLI_RESOURCE__0 from "! ${ DirectAngularResourceLoaderPath } ! ./app.component.html";
371
- import __NG_CLI_RESOURCE__1 from "./app.component.css";
323
+ import __NG_CLI_RESOURCE__0 from "./app.component.html?ngResource ";
324
+ import __NG_CLI_RESOURCE__1 from "./app.component.css?ngResource ";
372
325
373
326
import { Component } from '@angular/core';
374
327
0 commit comments