From 063adae77713f76e8dde22b02fde4d5b9b45efdf Mon Sep 17 00:00:00 2001 From: Fran Dios Date: Fri, 27 Nov 2020 03:07:17 +0900 Subject: [PATCH] Test: bypass import cache --- src/index.spec.ts | 9 +++++++++ tests/esm-import-cache/index.ts | 4 ++++ tests/esm-import-cache/log1.ts | 1 + tests/esm-import-cache/log2.ts | 1 + tests/esm-import-cache/package.json | 3 +++ tests/esm-import-cache/tsconfig.json | 7 +++++++ 6 files changed, 25 insertions(+) create mode 100644 tests/esm-import-cache/index.ts create mode 100644 tests/esm-import-cache/log1.ts create mode 100644 tests/esm-import-cache/log2.ts create mode 100644 tests/esm-import-cache/package.json create mode 100644 tests/esm-import-cache/tsconfig.json diff --git a/src/index.spec.ts b/src/index.spec.ts index 58fc64c56..bed91dd22 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -932,6 +932,15 @@ describe('ts-node', function () { }) }) + it('should bypass import cache when changing search params', (done) => { + exec(`${cmd} index.ts`, { cwd: join(__dirname, '../tests/esm-import-cache') }, function (err, stdout) { + expect(err).to.equal(null) + expect(stdout).to.equal('log1\nlog2\nlog2\n') + + return done() + }) + }) + it('should support transpile only mode via dedicated loader entrypoint', (done) => { exec(`${cmd}/transpile-only index.ts`, { cwd: join(__dirname, '../tests/esm-transpile-only') }, function (err, stdout) { expect(err).to.equal(null) diff --git a/tests/esm-import-cache/index.ts b/tests/esm-import-cache/index.ts new file mode 100644 index 000000000..5de8f1dac --- /dev/null +++ b/tests/esm-import-cache/index.ts @@ -0,0 +1,4 @@ +import './log1.js' +import './log1.js' +import './log2.js' +import './log2.js?bust' diff --git a/tests/esm-import-cache/log1.ts b/tests/esm-import-cache/log1.ts new file mode 100644 index 000000000..e33d05b5e --- /dev/null +++ b/tests/esm-import-cache/log1.ts @@ -0,0 +1 @@ +console.log('log1') diff --git a/tests/esm-import-cache/log2.ts b/tests/esm-import-cache/log2.ts new file mode 100644 index 000000000..efc53f2eb --- /dev/null +++ b/tests/esm-import-cache/log2.ts @@ -0,0 +1 @@ +console.log('log2') diff --git a/tests/esm-import-cache/package.json b/tests/esm-import-cache/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/tests/esm-import-cache/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/tests/esm-import-cache/tsconfig.json b/tests/esm-import-cache/tsconfig.json new file mode 100644 index 000000000..c5272e687 --- /dev/null +++ b/tests/esm-import-cache/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "module": "ESNext", + "allowJs": true, + "moduleResolution": "node" + } +}