From 774823ba4174aae5b16dda1fd7f2ff02210c6aab Mon Sep 17 00:00:00 2001 From: Kevin Marrec Date: Tue, 29 Jan 2019 20:19:21 +0100 Subject: [PATCH] fix tsconfig + remove forgotten duplicated test (#4886) --- packages/typescript/src/index.js | 5 ++- packages/typescript/test/setup.test.js | 5 ++- packages/typescript/tsconfig.json | 1 + test/unit/typescript.setup.test.js | 46 -------------------------- 4 files changed, 9 insertions(+), 48 deletions(-) delete mode 100644 test/unit/typescript.setup.test.js diff --git a/packages/typescript/src/index.js b/packages/typescript/src/index.js index c6ec5f4a5c..4631bdedd5 100644 --- a/packages/typescript/src/index.js +++ b/packages/typescript/src/index.js @@ -44,6 +44,9 @@ export async function setup(tsConfigPath) { } // https://github.com/TypeStrong/ts-node register({ - project: tsConfigPath + project: tsConfigPath, + compilerOptions: { + module: 'commonjs' + } }) } diff --git a/packages/typescript/test/setup.test.js b/packages/typescript/test/setup.test.js index f111a33fd8..2f50ed5829 100644 --- a/packages/typescript/test/setup.test.js +++ b/packages/typescript/test/setup.test.js @@ -35,7 +35,10 @@ describe('typescript setup', () => { expect(register).toHaveBeenCalledTimes(1) expect(register).toHaveBeenCalledWith({ - project: tsConfigPath + project: tsConfigPath, + compilerOptions: { + module: 'commonjs' + } }) }) diff --git a/packages/typescript/tsconfig.json b/packages/typescript/tsconfig.json index bd217e8b00..d4a6699b61 100644 --- a/packages/typescript/tsconfig.json +++ b/packages/typescript/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "target": "esnext", + "module": "esnext", "moduleResolution": "node", "lib": [ "esnext", diff --git a/test/unit/typescript.setup.test.js b/test/unit/typescript.setup.test.js deleted file mode 100644 index f111a33fd8..0000000000 --- a/test/unit/typescript.setup.test.js +++ /dev/null @@ -1,46 +0,0 @@ -import { resolve } from 'path' -import { exists, mkdirp, readJSON, remove } from 'fs-extra' -import { register } from 'ts-node' -import { setup as setupTypeScript } from '@nuxt/typescript' - -jest.mock('ts-node') - -describe('typescript setup', () => { - const rootDir = 'tmp' - const tsConfigPath = resolve(rootDir, 'tsconfig.json') - - beforeAll(async () => { - // We're assuming that rootDir provided to setupTypeScript is existing so we create the tested one - await mkdirp(rootDir) - await setupTypeScript(tsConfigPath) - }) - - test('tsconfig.json has been generated if missing', async () => { - expect(await exists(tsConfigPath)).toBe(true) - expect(await readJSON(tsConfigPath)).toEqual({ - extends: '@nuxt/typescript', - compilerOptions: { - baseUrl: '.', - types: [ - '@types/node', - '@nuxt/vue-app' - ] - } - }) - }) - - test('ts-node has been registered once', async () => { - // Call setupTypeScript a second time to test guard - await setupTypeScript(tsConfigPath) - - expect(register).toHaveBeenCalledTimes(1) - expect(register).toHaveBeenCalledWith({ - project: tsConfigPath - }) - }) - - afterAll(async () => { - // Clean workspace by removing the temporary folder (and the generated tsconfig.json at the same time) - await remove(tsConfigPath) - }) -})