diff --git a/.eslintrc.js b/.eslintrc.js index 0dd96cdf4..df99b1421 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -47,7 +47,16 @@ module.exports = { }, }, { - files: ['test-packages/**/*.[jt]s', 'tests/scenarios/**/*.{js,ts}'], + files: ['test-packages/**/*.[jt]s'], + rules: { + 'import/no-extraneous-dependencies': 'off', + }, + }, + { + files: ['tests/scenarios/**/*.ts'], + parserOptions: { + project: './tests/scenarios/tsconfig.json', + }, rules: { 'import/no-extraneous-dependencies': 'off', }, diff --git a/package.json b/package.json index 92d8e2e17..a95e150f3 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ }, "scripts": { "clean": "git clean -x -f", - "compile": "tsc", + "compile": "tsc -b", "dev": "tsc -b --watch", "lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'", "lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'", @@ -15,7 +15,7 @@ "lint:prettier": "prettier . -c", "lint:prettier:fix": "prettier . -w", "lint:router-types": "cd packages/router && pnpm lint:types", - "prepare": "tsc && pnpm build-v2-addons", + "prepare": "tsc -b && pnpm build-v2-addons", "build-v2-addons": "concurrently 'pnpm:build-v2-addons:*'", "build-v2-addons:router": "cd packages/router && pnpm build", "test": "cd tests/scenarios && pnpm test" diff --git a/packages/core/package.json b/packages/core/package.json index 32614b34c..5165df7af 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -62,6 +62,7 @@ "@types/resolve": "^1.20.0", "@types/semver": "^7.3.5", "@types/tmp": "^0.1.0", + "@types/qunit": "^2.11.1", "fixturify": "^2.1.1", "tmp": "^0.1.0", "typescript": "^5.1.6" diff --git a/packages/core/src/messages.ts b/packages/core/src/messages.ts index 4b5368551..940e9ef14 100644 --- a/packages/core/src/messages.ts +++ b/packages/core/src/messages.ts @@ -1,6 +1,10 @@ import makeDebug from 'debug'; import { format } from 'util'; +// @ts-expect-error +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import type qunit from 'qunit'; + const todo = makeDebug('embroider:todo'); const unsupported = makeDebug('embroider:unsupported'); const debug = makeDebug('embroider:debug'); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fc86b9c56..495f7308a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -373,7 +373,7 @@ importers: version: 1.7.0 code-equality-assertions: specifier: ^0.9.0 - version: 0.9.0(@types/jest@29.5.12)(qunit@2.21.0) + version: 0.9.0(@types/jest@29.5.12)(@types/qunit@2.19.10)(qunit@2.21.0) ember-engines: specifier: ^0.8.19 version: 0.8.23(@glint/template@1.4.0) @@ -498,6 +498,9 @@ importers: '@types/node': specifier: ^15.12.2 version: 15.14.9 + '@types/qunit': + specifier: ^2.11.1 + version: 2.19.10 '@types/resolve': specifier: ^1.20.0 version: 1.20.6 @@ -606,7 +609,7 @@ importers: version: 2.2.5 code-equality-assertions: specifier: ^0.9.0 - version: 0.9.0(@types/jest@29.5.12)(qunit@2.21.0) + version: 0.9.0(@types/jest@29.5.12)(@types/qunit@2.19.10)(qunit@2.21.0) scenario-tester: specifier: ^2.1.2 version: 2.1.2 @@ -1219,7 +1222,7 @@ importers: version: 3.5.2 code-equality-assertions: specifier: ^0.9.0 - version: 0.9.0(@types/jest@29.5.12)(qunit@2.21.0) + version: 0.9.0(@types/jest@29.5.12)(@types/qunit@2.19.10)(qunit@2.21.0) console-ui: specifier: ^3.0.0 version: 3.1.2 @@ -1281,6 +1284,9 @@ importers: '@types/node': specifier: ^10.5.2 version: 10.17.60 + '@types/qunit': + specifier: ^2.11.1 + version: 2.19.10 test-packages/unstable-release: dependencies: @@ -8922,9 +8928,6 @@ packages: /ajv-formats@2.1.1: resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} - peerDependenciesMeta: - ajv: - optional: true dependencies: ajv: 8.16.0 @@ -11436,7 +11439,7 @@ packages: q: 1.5.1 dev: true - /code-equality-assertions@0.9.0(@types/jest@29.5.12)(qunit@2.21.0): + /code-equality-assertions@0.9.0(@types/jest@29.5.12)(@types/qunit@2.19.10)(qunit@2.21.0): resolution: {integrity: sha512-8t2+ZiCU9TIr/78TyVSEFii9khSic293zVCfndsG7bOymAsdDFmN1GSwjRdyQxz7+tHE+biUvt08Qlx4Xvfuxw==} peerDependencies: '@types/jest': '2' @@ -11452,6 +11455,7 @@ packages: dependencies: '@babel/core': 7.24.7 '@types/jest': 29.5.12 + '@types/qunit': 2.19.10 diff: 5.2.0 prettier: 2.8.8 qunit: 2.21.0 diff --git a/test-packages/support/package.json b/test-packages/support/package.json index 3c36cabbb..62750bedb 100644 --- a/test-packages/support/package.json +++ b/test-packages/support/package.json @@ -33,6 +33,7 @@ "@types/babel__traverse": "^7.18.5", "@types/fs-extra": "^9.0.12", "@types/lodash": "^4.14.170", - "@types/node": "^10.5.2" + "@types/node": "^10.5.2", + "@types/qunit": "^2.11.1" } } diff --git a/tests/scenarios/compat-plugin-hints-test.ts b/tests/scenarios/compat-plugin-hints-test.ts index 05515f53c..07e865b5c 100644 --- a/tests/scenarios/compat-plugin-hints-test.ts +++ b/tests/scenarios/compat-plugin-hints-test.ts @@ -8,13 +8,13 @@ import { join } from 'path'; import QUnit from 'qunit'; const { module: Qmodule, test } = QUnit; -export function samplePlugin() { - return { visitor: {} }; -} - appScenarios .map('compat-plugin-hints', app => { - app.files['ember-cli-build.js'] = ` + app.mergeFiles({ + 'sample-plugin.js': `module.exports.samplePlugin = function samplePlugin() { + return { visitor: {} }; + }`, + 'ember-cli-build.js': ` 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); @@ -25,7 +25,7 @@ appScenarios babel: { plugins: [ // deliberately non-serializable form - require("${__filename.replace(/\\/g, '/').replace(/\.ts$/, '.js')}").samplePlugin + require(__dirname + '/sample-plugin.js').samplePlugin ] } }); @@ -38,13 +38,14 @@ appScenarios ], pluginHints: [ { - resolve: ["${__filename.replace(/\\/g, '/').replace(/\.ts$/, '.js')}"], + resolve: [__dirname + '/sample-plugin.js'], useMethod: 'samplePlugin', }, ], }); }; - `; + `, + }); }) .forEachScenario(scenario => { Qmodule(scenario.name, function (hooks) { diff --git a/tests/scenarios/router-test.ts b/tests/scenarios/router-test.ts index 519742f06..9cdf46e13 100644 --- a/tests/scenarios/router-test.ts +++ b/tests/scenarios/router-test.ts @@ -18,7 +18,7 @@ let routerApp = tsAppScenarios.map('router', project => { const EmberApp = require('ember-cli/lib/broccoli/ember-app'); const { maybeEmbroider } = require('@embroider/test-setup'); - + module.exports = function (defaults) { let app = new EmberApp(defaults, { 'ember-cli-babel': { @@ -30,7 +30,7 @@ let routerApp = tsAppScenarios.map('router', project => { } } }); - + return maybeEmbroider(app, { staticAddonTestSupportTrees: true, staticAddonTrees: true, @@ -219,7 +219,7 @@ let routerApp = tsAppScenarios.map('router', project => { ); }); }); - + `, }, }, @@ -234,7 +234,7 @@ routerApp.forEachScenario(scenario => { }); test(`type checks`, async function (assert) { - let result = await app.execute('pnpm tsc'); + let result = await app.execute('pnpm tsc -b'); assert.equal(result.exitCode, 0, result.output); }); }); diff --git a/tests/scenarios/tsconfig.json b/tests/scenarios/tsconfig.json new file mode 100644 index 000000000..607f4f3f7 --- /dev/null +++ b/tests/scenarios/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig-base", + "include": ["*.ts"], + "compilerOptions": { + "rootDir": ".", + "outDir": "./build" + } +} diff --git a/tests/scenarios/typescript-app-test.ts b/tests/scenarios/typescript-app-test.ts index 5f2703f52..37a5d287a 100644 --- a/tests/scenarios/typescript-app-test.ts +++ b/tests/scenarios/typescript-app-test.ts @@ -86,7 +86,7 @@ typescriptApp.forEachScenario(scenario => { }); test(`check types`, async function (assert) { - let result = await app.execute(`pnpm tsc`); + let result = await app.execute(`pnpm tsc -b`); assert.equal(result.exitCode, 0, result.output); }); }); diff --git a/tsconfig-base.json b/tsconfig-base.json new file mode 100644 index 000000000..a3022d66b --- /dev/null +++ b/tsconfig-base.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "es2019", + "module": "commonjs", + "declaration": true, + "typeRoots": ["types", "node_modules/@types"], + "esModuleInterop": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "sourceMap": true, + "inlineSources": true, + "experimentalDecorators": true, + "allowUnreachableCode": false, + "strict": true, + "skipLibCheck": true, + "useUnknownInCatchVariables": false, + }, +} diff --git a/tsconfig.json b/tsconfig.json index 382d5af75..9da9b9dfd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,27 +1,11 @@ { + "extends": "./tsconfig-base", "include": [ "./packages/*/src/**/*.ts", "./packages/*/tests/**/*.ts", "./test-packages/support/**/*.ts", - "./test-packages/release/src/**/*.ts", - "./tests/scenarios/**/*.ts" + "./test-packages/release/src/**/*.ts" ], - "compilerOptions": { - "target": "es2019", - "module": "commonjs", - "declaration": true, - "typeRoots": ["types", "node_modules/@types"], - "esModuleInterop": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "sourceMap": true, - "inlineSources": true, - "experimentalDecorators": true, - "allowUnreachableCode": false, - "strict": true, - "skipLibCheck": true, - "useUnknownInCatchVariables": false, - }, "exclude": [ "node_modules", "packages/*/tmp",