Skip to content

Commit 3ef41c0

Browse files
committed
Add a check for process
1 parent 7a79010 commit 3ef41c0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/firestore/rollup.config.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,20 @@ function importMetaUrlPolyfillPlugin(filename) {
4545
name: 'import-meta-url-current-module',
4646
resolveImportMeta(property, { moduleId }) {
4747
if (property === 'url') {
48-
// Copied from rollup output
4948
// 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
5056
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 && ` +
5560
`document.currentScript.src || new URL('${filename}', ` +
56-
'document.baseURI).href))'
61+
`document.baseURI).href))`
5762
);
5863
}
5964
return null;

0 commit comments

Comments
 (0)