@@ -24,7 +24,7 @@ interface BrowserHttpImportPluginOptions {
24
24
/**
25
25
* Convert imports of dependencies in node modules to http imports from esm cdn.
26
26
*/
27
- export class BrowserImportEsmPlugin {
27
+ export class BrowserHttpImportEsmPlugin {
28
28
constructor ( private options : BrowserHttpImportPluginOptions = { } ) { }
29
29
30
30
apply ( compiler : Compiler ) {
@@ -33,6 +33,12 @@ export class BrowserImportEsmPlugin {
33
33
const request = resolveData . request ;
34
34
const packageName = getPackageName ( request ) ;
35
35
36
+ // We don't consider match resource and inline loaders
37
+ // Because usually they are not used with dependent modules like `sass-loader?react`
38
+ if ( request . includes ( "!" ) ) {
39
+ return ;
40
+ }
41
+
36
42
// If dependencyUrl is provided, use it to resolve the request
37
43
if ( this . options . dependencyUrl ) {
38
44
if ( typeof this . options . dependencyUrl === "function" ) {
@@ -51,7 +57,7 @@ export class BrowserImportEsmPlugin {
51
57
}
52
58
53
59
// If the issuer is a URL, request must be relative to that URL too
54
- const issuerUrl = toUrl ( resolveData . contextInfo . issuer ) ;
60
+ const issuerUrl = toHttpUrl ( resolveData . contextInfo . issuer ) ;
55
61
if ( issuerUrl ) {
56
62
resolveData . request = this . resolveWithUrlIssuer ( request , issuerUrl ) ;
57
63
return ;
@@ -85,7 +91,7 @@ export class BrowserImportEsmPlugin {
85
91
86
92
isNodeModule ( request : string ) {
87
93
// Skip requests like "http://xxx"
88
- if ( toUrl ( request ) ) {
94
+ if ( toHttpUrl ( request ) ) {
89
95
return false ;
90
96
}
91
97
@@ -137,10 +143,12 @@ function getRequestWithVersion(request: string, version: string) {
137
143
}
138
144
}
139
145
140
- function toUrl ( request : string ) : URL | undefined {
146
+ function toHttpUrl ( request : string ) : URL | undefined {
141
147
try {
142
148
const url = new URL ( request ) ;
143
- return url ;
149
+ if ( url . protocol === "http:" || url . protocol === "https:" ) {
150
+ return url ;
151
+ }
144
152
} catch {
145
153
return undefined ;
146
154
}
0 commit comments