File tree 1 file changed +11
-6
lines changed 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -45,15 +45,20 @@ function importMetaUrlPolyfillPlugin(filename) {
45
45
name : 'import-meta-url-current-module' ,
46
46
resolveImportMeta ( property , { moduleId } ) {
47
47
if ( property === 'url' ) {
48
- // Copied from rollup output
49
48
// Added a check for Jest (see issue 5687 linked above)
49
+ // See https://jestjs.io/docs/environment-variables - apparently
50
+ // these are not always both set.
51
+ const JEST_CHECK =
52
+ `typeof process !== 'undefined' && process.env !== undefined` +
53
+ ` && (process.env.JEST_WORKER_ID !== undefined || ` +
54
+ `process.env.NODE_ENV === 'test')` ;
55
+ // Copied from rollup output
50
56
return (
51
- "((typeof document === 'undefined' || process.env.JEST_WORKER_ID " +
52
- "!== undefined || process.env.NODE_ENV === 'test') ?" +
53
- " new (require('url').URL)" +
54
- "('file:' + __filename).href : (document.currentScript && " +
57
+ `((typeof document === 'undefined' || (${ JEST_CHECK } )) ?` +
58
+ ` new (require('url').URL)` +
59
+ `('file:' + __filename).href : (document.currentScript && ` +
55
60
`document.currentScript.src || new URL('${ filename } ', ` +
56
- ' document.baseURI).href))'
61
+ ` document.baseURI).href))`
57
62
) ;
58
63
}
59
64
return null ;
You can’t perform that action at this time.
0 commit comments