Skip to content

Commit

Permalink
solution 3
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-leonov committed Jan 29, 2020
1 parent 68c94d1 commit 3b718bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/jest-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ class Runtime {
loaded: false,
};
moduleRegistry[modulePath] = localModule;
if (path.extname(modulePath) === '.json') {
if (path.extname(modulePath.split('?')[0]) === '.json') {
localModule.exports = this._environment.global.JSON.parse(
stripBOM(fs.readFileSync(modulePath, 'utf8')),
stripBOM(fs.readFileSync(modulePath.split('?')[0], 'utf8')),
);
} else if (path.extname(modulePath) === '.node') {
// $FlowFixMe
Expand Down Expand Up @@ -422,7 +422,7 @@ class Runtime {
'__mocks__',
moduleFileName,
);
if (fs.existsSync(potentialManualMock)) {
if (fs.existsSync(potentialManualMock.split('?')[0])) {
isManualMock = true;
modulePath = potentialManualMock;
}
Expand Down Expand Up @@ -520,7 +520,7 @@ class Runtime {
if (
coveredFiles.has(sourcePath) &&
this._needsCoverageMapped.has(sourcePath) &&
fs.existsSync(this._sourceMapRegistry[sourcePath])
fs.existsSync(this._sourceMapRegistry[sourcePath].split('?')[0])
) {
result[sourcePath] = this._sourceMapRegistry[sourcePath];
}
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-transform/src/ScriptTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export default class ScriptTransformer {
const isInternalModule = !!(options && options.isInternalModule);
const isCoreModule = !!(options && options.isCoreModule);
const content = stripShebang(
fileSource || fs.readFileSync(filename, 'utf8'),
fileSource || fs.readFileSync(filename.split('?')[0], 'utf8'),
);

let wrappedCode: string;
Expand Down Expand Up @@ -511,7 +511,7 @@ const readCacheFile = (cachePath: Path): ?string => {
};

const getScriptCacheKey = (filename, instrument: boolean) => {
const mtime = fs.statSync(filename).mtime;
const mtime = fs.statSync(filename.split('?')[0]).mtime;
return filename + '_' + mtime.getTime() + (instrument ? '_instrumented' : '');
};

Expand Down

0 comments on commit 3b718bc

Please sign in to comment.