File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
packages/ngtools/webpack/src/ivy Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import * as path from 'path';
10
10
import type { LoaderContext } from 'webpack' ;
11
11
import { AngularPluginSymbol , FileEmitterCollection } from './symbol' ;
12
12
13
+ const JS_FILE_REGEXP = / \. [ c m ] ? j s $ / ;
14
+
13
15
export function angularWebpackLoader ( this : LoaderContext < unknown > , content : string , map : string ) {
14
16
const callback = this . async ( ) ;
15
17
if ( ! callback ) {
@@ -20,7 +22,7 @@ export function angularWebpackLoader(this: LoaderContext<unknown>, content: stri
20
22
this as LoaderContext < unknown > & { [ AngularPluginSymbol ] ?: FileEmitterCollection }
21
23
) [ AngularPluginSymbol ] ;
22
24
if ( ! fileEmitter || typeof fileEmitter !== 'object' ) {
23
- if ( this . resourcePath . endsWith ( '.js' ) ) {
25
+ if ( JS_FILE_REGEXP . test ( this . resourcePath ) ) {
24
26
// Passthrough for JS files when no plugin is used
25
27
this . callback ( undefined , content , map ) ;
26
28
@@ -36,7 +38,7 @@ export function angularWebpackLoader(this: LoaderContext<unknown>, content: stri
36
38
. emit ( this . resourcePath )
37
39
. then ( ( result ) => {
38
40
if ( ! result ) {
39
- if ( this . resourcePath . endsWith ( '.js' ) ) {
41
+ if ( JS_FILE_REGEXP . test ( this . resourcePath ) ) {
40
42
// Return original content for JS files if not compiled by TypeScript ("allowJs")
41
43
this . callback ( undefined , content , map ) ;
42
44
} else {
You can’t perform that action at this time.
0 commit comments