From 695c7465138c01315be1ee11b2cad4b27530920d Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Mon, 9 Dec 2024 19:59:07 +0100 Subject: [PATCH 01/12] Fix type error on stable Stable is broken when running pnpm without the lockfile: ``` packages/macros/tests/babel/helpers.ts:85:15 - error TS2454: Variable 'mode' is used before being assigned. ``` Applying same fix as on `main`: https://github.com/embroider-build/embroider/pull/2184/commits/31ed2c223e446b744962d96ab58712199551fd37 --- packages/macros/tests/babel/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/macros/tests/babel/helpers.ts b/packages/macros/tests/babel/helpers.ts index 1d69bca37..ceebfa66b 100644 --- a/packages/macros/tests/babel/helpers.ts +++ b/packages/macros/tests/babel/helpers.ts @@ -79,7 +79,7 @@ disabledTest.failing = disabledTest; export function allModes(fn: CreateModeTests): CreateTests { return function createTests(transform: Transform) { - for (let mode of ['build-time', 'run-time']) { + for (const mode of ['build-time', 'run-time']) { describe(mode, function () { function applyMode(macrosConfig: MacrosConfig) { if (mode === 'run-time') { From a2dd3072f2d6f863397e31a89d3a1aa8811e72e3 Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Tue, 10 Dec 2024 10:28:58 +0100 Subject: [PATCH 02/12] Disable prototype extensions --- .../sample-transforms/tests/dummy/config/environment.js | 5 +---- tests/fixtures/fastboot-app/config/environment.js | 5 +---- tests/fixtures/macro-test/config/environment.js | 5 +---- tests/scenarios/compat-route-split-test.ts | 8 ++------ tests/scenarios/compat-template-colocation-test.ts | 4 +--- 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/test-packages/sample-transforms/tests/dummy/config/environment.js b/test-packages/sample-transforms/tests/dummy/config/environment.js index 93d69f559..ca0f32bd5 100644 --- a/test-packages/sample-transforms/tests/dummy/config/environment.js +++ b/test-packages/sample-transforms/tests/dummy/config/environment.js @@ -11,10 +11,7 @@ module.exports = function (environment) { // Here you can enable experimental features on an ember canary build // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true }, - EXTEND_PROTOTYPES: { - // Prevent Ember Data from overriding Date.parse. - Date: false, - }, + EXTEND_PROTOTYPES: false, }, APP: { diff --git a/tests/fixtures/fastboot-app/config/environment.js b/tests/fixtures/fastboot-app/config/environment.js index 7599ea68c..45a681a96 100644 --- a/tests/fixtures/fastboot-app/config/environment.js +++ b/tests/fixtures/fastboot-app/config/environment.js @@ -11,10 +11,7 @@ module.exports = function (environment) { // Here you can enable experimental features on an ember canary build // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true }, - EXTEND_PROTOTYPES: { - // Prevent Ember Data from overriding Date.parse. - Date: false, - }, + EXTEND_PROTOTYPES: false, }, fastboot: { hostWhitelist: ['localhost:4200'], diff --git a/tests/fixtures/macro-test/config/environment.js b/tests/fixtures/macro-test/config/environment.js index c505695c0..82d921468 100644 --- a/tests/fixtures/macro-test/config/environment.js +++ b/tests/fixtures/macro-test/config/environment.js @@ -11,10 +11,7 @@ module.exports = function (environment) { // Here you can enable experimental features on an ember canary build // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true }, - EXTEND_PROTOTYPES: { - // Prevent Ember Data from overriding Date.parse. - Date: false, - }, + EXTEND_PROTOTYPES: false, }, APP: { diff --git a/tests/scenarios/compat-route-split-test.ts b/tests/scenarios/compat-route-split-test.ts index 2b7f30ea0..181324a86 100644 --- a/tests/scenarios/compat-route-split-test.ts +++ b/tests/scenarios/compat-route-split-test.ts @@ -240,9 +240,7 @@ splitScenarios EmberENV: { FEATURES: { }, - EXTEND_PROTOTYPES: { - Date: false - } + EXTEND_PROTOTYPES: false, }, APP: {} }; @@ -412,9 +410,7 @@ splitScenarios EmberENV: { FEATURES: { }, - EXTEND_PROTOTYPES: { - Date: false - } + EXTEND_PROTOTYPES: false, }, APP: {} }; diff --git a/tests/scenarios/compat-template-colocation-test.ts b/tests/scenarios/compat-template-colocation-test.ts index c845435b8..8b978b59b 100644 --- a/tests/scenarios/compat-template-colocation-test.ts +++ b/tests/scenarios/compat-template-colocation-test.ts @@ -244,9 +244,7 @@ appScenarios EmberENV: { FEATURES: { }, - EXTEND_PROTOTYPES: { - Date: false - } + EXTEND_PROTOTYPES: false, }, APP: {} }; From 84204f7df518ee0765224b44f8888cd0c255e232 Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Tue, 10 Dec 2024 10:34:36 +0100 Subject: [PATCH 03/12] Fix compat-resolver-test --- tests/scenarios/compat-resolver-test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/scenarios/compat-resolver-test.ts b/tests/scenarios/compat-resolver-test.ts index d59a67b50..281cc1a1b 100644 --- a/tests/scenarios/compat-resolver-test.ts +++ b/tests/scenarios/compat-resolver-test.ts @@ -69,7 +69,6 @@ Scenarios.fromProject(() => new Project()) emberVersion = '4.6.0' //based on app-template package.json ) { let etcOptions: EtcOptions = { - compilerPath: require.resolve('ember-source-latest/dist/ember-template-compiler'), targetFormat: 'hbs', transforms: [ ...(extraOpts?.astPlugins ?? []), From 287b310bcadc294c770abf6b44e7bd792a1d3b19 Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Tue, 10 Dec 2024 10:56:20 +0100 Subject: [PATCH 04/12] Fix compilerPath --- tests/scenarios/v2-addon-dev-test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scenarios/v2-addon-dev-test.ts b/tests/scenarios/v2-addon-dev-test.ts index a488869a1..b359c0adb 100644 --- a/tests/scenarios/v2-addon-dev-test.ts +++ b/tests/scenarios/v2-addon-dev-test.ts @@ -35,7 +35,7 @@ appScenarios "@babel/plugin-transform-class-static-block", ["babel-plugin-ember-template-compilation", { targetFormat: 'hbs', - compilerPath: 'ember-source/dist/ember-template-compiler', + compilerPath: 'ember-source/dist/ember-template-compiler.js', transforms: [ './lib/custom-transform.js', ], @@ -187,7 +187,7 @@ appScenarios "@babel/plugin-transform-class-static-block", ["babel-plugin-ember-template-compilation", { targetFormat: 'hbs', - compilerPath: 'ember-source/dist/ember-template-compiler', + compilerPath: 'ember-source/dist/ember-template-compiler.js', }], ["@babel/plugin-proposal-decorators", { "legacy": true }], [ "@babel/plugin-transform-class-properties" ] From de5cf52fe6e1f2a0c19abb6769822b4846052e6b Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Tue, 10 Dec 2024 11:03:46 +0100 Subject: [PATCH 05/12] Run static-with-rules tests on 5.12 only --- tests/scenarios/compat-stage2-test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/scenarios/compat-stage2-test.ts b/tests/scenarios/compat-stage2-test.ts index 8928ec823..547edb0a7 100644 --- a/tests/scenarios/compat-stage2-test.ts +++ b/tests/scenarios/compat-stage2-test.ts @@ -334,6 +334,9 @@ stage2Scenarios }); stage2Scenarios + // last release that supports non-colocated templates (which is part of what + // this test is testing) + .only('lts_5_12') .map('static-with-rules', app => { app.addDependency('some-library', '1.0.0'); app.linkDependency('@embroider/sample-transforms', { baseDir: __dirname }); From fa599211f233fad98057d2dc2af45c14d06344a1 Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Tue, 10 Dec 2024 11:09:14 +0100 Subject: [PATCH 06/12] Add 5.12 scenario --- tests/scenarios/compat-stage2-test.ts | 2 +- tests/scenarios/package.json | 2 ++ tests/scenarios/scenarios.ts | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/scenarios/compat-stage2-test.ts b/tests/scenarios/compat-stage2-test.ts index 547edb0a7..290c7a051 100644 --- a/tests/scenarios/compat-stage2-test.ts +++ b/tests/scenarios/compat-stage2-test.ts @@ -336,7 +336,7 @@ stage2Scenarios stage2Scenarios // last release that supports non-colocated templates (which is part of what // this test is testing) - .only('lts_5_12') + .only('lts_5_12-compat-stage2-build') .map('static-with-rules', app => { app.addDependency('some-library', '1.0.0'); app.linkDependency('@embroider/sample-transforms', { baseDir: __dirname }); diff --git a/tests/scenarios/package.json b/tests/scenarios/package.json index 6b60d000e..1316556fd 100644 --- a/tests/scenarios/package.json +++ b/tests/scenarios/package.json @@ -69,6 +69,7 @@ "ember-cli-4.8": "npm:ember-cli@~4.8.0", "ember-cli-5.4": "npm:ember-cli@~5.4.0", "ember-cli-5.8": "npm:ember-cli@~5.8.0", + "ember-cli-5.12": "npm:ember-cli@~5.12.0", "ember-cli-babel-latest": "npm:ember-cli-babel@latest", "ember-cli-beta": "npm:ember-cli@beta", "ember-cli-fastboot": "^4.1.1", @@ -90,6 +91,7 @@ "ember-source-4.8": "npm:ember-source@~4.8.0", "ember-source-5.4": "npm:ember-source@~5.4.0", "ember-source-5.8": "npm:ember-source@~5.8.0", + "ember-source-5.12": "npm:ember-source@~5.12.0", "ember-source-beta": "npm:ember-source@beta", "ember-source-canary": "https://s3.amazonaws.com/builds.emberjs.com/canary/shas/756f0e3f98b8ca5edf443fe57318b4dac692bffa.tgz", "ember-source-latest": "npm:ember-source@latest", diff --git a/tests/scenarios/scenarios.ts b/tests/scenarios/scenarios.ts index bd13ded3e..b9a8ce2eb 100644 --- a/tests/scenarios/scenarios.ts +++ b/tests/scenarios/scenarios.ts @@ -41,6 +41,14 @@ async function lts_5_8(project: Project) { project.linkDevDependency('@ember/test-waiters', { baseDir: __dirname, resolveName: '@ember/test-waiters' }); } +async function lts_5_12(project: Project) { + project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-5.12' }); + project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-5.12' }); + project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-5.3' }); + project.linkDevDependency('ember-cli-babel', { baseDir: __dirname, resolveName: 'ember-cli-babel-latest' }); + project.linkDevDependency('@ember/test-waiters', { baseDir: __dirname, resolveName: '@ember/test-waiters' }); +} + async function release(project: Project) { project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-latest' }); project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-latest' }); @@ -75,6 +83,7 @@ export function supportMatrix(scenarios: Scenarios) { return scenarios.expand({ lts_3_28, lts_4_4, + lts_5_12, release, }); } @@ -87,6 +96,7 @@ export function fullSupportMatrix(scenarios: Scenarios) { lts_4_12, lts_5_4, lts_5_8, + lts_5_12, release, beta, canary, From cf647ee2f9c65431cf5f375211653a0d387a0b3f Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Tue, 10 Dec 2024 11:10:41 +0100 Subject: [PATCH 07/12] Fix removed action modifier usage --- pnpm-lock.yaml | 6 ++++++ .../tests/integration/components/macro-if-test.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5f21424e5..c48bb6fc9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1727,6 +1727,9 @@ importers: ember-cli-4.8: specifier: npm:ember-cli@~4.8.0 version: /ember-cli@4.8.1 + ember-cli-5.12: + specifier: npm:ember-cli@~5.12.0 + version: /ember-cli@5.12.0 ember-cli-5.4: specifier: npm:ember-cli@~5.4.0 version: /ember-cli@5.4.2 @@ -1790,6 +1793,9 @@ importers: ember-source-4.8: specifier: npm:ember-source@~4.8.0 version: /ember-source@4.8.6(@babel/core@7.26.0) + ember-source-5.12: + specifier: npm:ember-source@~5.12.0 + version: /ember-source@5.12.0 ember-source-5.4: specifier: npm:ember-source@~5.4.0 version: /ember-source@5.4.1(@babel/core@7.26.0) diff --git a/tests/fixtures/macro-test/tests/integration/components/macro-if-test.js b/tests/fixtures/macro-test/tests/integration/components/macro-if-test.js index 8870cc8ce..835a7707a 100644 --- a/tests/fixtures/macro-test/tests/integration/components/macro-if-test.js +++ b/tests/fixtures/macro-test/tests/integration/components/macro-if-test.js @@ -88,7 +88,7 @@ module('Integration | Macro | macroCondition', function (hooks) { assert.ok(true, 'it ran'); }; await render( - hbs`
` + hbs`
` ); let target = this.element.querySelector('[data-test-target]'); await click(target); From 6727e38eee788aaf292fa983943171bd4342dc10 Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Tue, 10 Dec 2024 12:04:44 +0100 Subject: [PATCH 08/12] Skip lts_4_4 --- tests/scenarios/scenarios.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/scenarios/scenarios.ts b/tests/scenarios/scenarios.ts index b9a8ce2eb..84d3d81cd 100644 --- a/tests/scenarios/scenarios.ts +++ b/tests/scenarios/scenarios.ts @@ -80,12 +80,17 @@ async function canary(project: Project) { } export function supportMatrix(scenarios: Scenarios) { - return scenarios.expand({ - lts_3_28, - lts_4_4, - lts_5_12, - release, - }); + return ( + scenarios + .expand({ + lts_3_28, + lts_4_4, + lts_5_12, + release, + }) + // exceeding GitHub actions limit of 256 + .skip('lts_4_4') + ); } export function fullSupportMatrix(scenarios: Scenarios) { From db64cec5e6118358fb86311b8dde1d8de77165b4 Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Tue, 10 Dec 2024 13:12:10 +0100 Subject: [PATCH 09/12] Skip engines tests --- tests/scenarios/engines-test.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/scenarios/engines-test.ts b/tests/scenarios/engines-test.ts index 4f147254b..4e7663b31 100644 --- a/tests/scenarios/engines-test.ts +++ b/tests/scenarios/engines-test.ts @@ -81,9 +81,7 @@ let engineScenarios = appScenarios.map('engines', project => { }); engineScenarios - .skip('lts_3_28-engines') // this skip should be removed before https://github.com/embroider-build/embroider/pull/1435 is merged - .skip('lts_4_4-engines') // this skip should be removed before https://github.com/embroider-build/embroider/pull/1435 is merged - .skip('release-engines') // this skip should be removed before https://github.com/embroider-build/embroider/pull/1435 is merged + .skip() .map('without-fastboot', () => {}) .forEachScenario(scenario => { Qmodule(scenario.name, function (hooks) { @@ -137,9 +135,7 @@ engineScenarios }); engineScenarios - .skip('lts_3_28-engines') // fails due to https://github.com/emberjs/ember.js/pull/20461 - .skip('lts_4_4-engines') // fails due to https://github.com/emberjs/ember.js/pull/20461 - .skip('release-engines') // fails due to https://github.com/emberjs/ember.js/pull/20461 + .skip() .map('with-fastboot', app => { app.linkDependency('ember-cli-fastboot', { baseDir: __dirname }); app.linkDependency('fastboot', { baseDir: __dirname }); From 337b7f0269c1a0e5bed3e02419c4e19978b5136e Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Tue, 10 Dec 2024 13:21:37 +0100 Subject: [PATCH 10/12] Run codemod tests with 5.12 --- tests/scenarios/template-tag-codemod-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scenarios/template-tag-codemod-test.ts b/tests/scenarios/template-tag-codemod-test.ts index 1f253d250..575a7d842 100644 --- a/tests/scenarios/template-tag-codemod-test.ts +++ b/tests/scenarios/template-tag-codemod-test.ts @@ -6,7 +6,7 @@ import { join } from 'path'; const { module: Qmodule, test } = QUnit; appScenarios - .only('release') + .only('lts_5_12') .map('template-tag-codemod', project => { project.mergeFiles({ app: { From 1124f06a19c557eaf6fd9b2b0b8f0cdbd75a7a3f Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Mon, 9 Dec 2024 18:40:36 +0100 Subject: [PATCH 11/12] Add rollup declarations plugin This invokes glint as a rollup plugin, and contains a workaround for broken gts imports, see https://github.com/typed-ember/glint/issues/628 --- packages/addon-dev/jest.config.js | 6 + packages/addon-dev/package.json | 7 +- packages/addon-dev/src/rollup-declarations.ts | 50 ++++++++ packages/addon-dev/src/rollup.ts | 5 + packages/addon-dev/tests/declarations.test.ts | 112 ++++++++++++++++++ pnpm-lock.yaml | 96 ++++++++++++++- 6 files changed, 272 insertions(+), 4 deletions(-) create mode 100644 packages/addon-dev/jest.config.js create mode 100644 packages/addon-dev/src/rollup-declarations.ts create mode 100644 packages/addon-dev/tests/declarations.test.ts diff --git a/packages/addon-dev/jest.config.js b/packages/addon-dev/jest.config.js new file mode 100644 index 000000000..7f4f45dca --- /dev/null +++ b/packages/addon-dev/jest.config.js @@ -0,0 +1,6 @@ +module.exports = { + testEnvironment: 'node', + testMatch: [ + '/tests/**/*.test.js', + ], +}; diff --git a/packages/addon-dev/package.json b/packages/addon-dev/package.json index 310b3f209..b08385c3a 100644 --- a/packages/addon-dev/package.json +++ b/packages/addon-dev/package.json @@ -37,6 +37,7 @@ "@embroider/core": "workspace:^", "@rollup/pluginutils": "^4.1.1", "content-tag": "^3.0.0", + "execa": "^5.1.1", "fs-extra": "^10.0.0", "minimatch": "^3.0.4", "rollup-plugin-copy-assets": "^2.0.3", @@ -46,11 +47,15 @@ "devDependencies": { "@embroider/test-support": "workspace:*", "@glimmer/syntax": "^0.84.2", + "@glint/core": "^1.5.0", + "@glint/template": "^1.5.0", + "@glint/environment-ember-loose": "^1.5.0", + "@glint/environment-ember-template-imports": "^1.5.0", "@types/fs-extra": "^9.0.12", "@types/minimatch": "^3.0.4", "@types/yargs": "^17.0.3", "rollup": "^3.23.0", - "tmp": "^0.1.0", + "scenario-tester": "^4.0.0", "typescript": "^5.4.5" }, "engines": { diff --git a/packages/addon-dev/src/rollup-declarations.ts b/packages/addon-dev/src/rollup-declarations.ts new file mode 100644 index 000000000..89db68851 --- /dev/null +++ b/packages/addon-dev/src/rollup-declarations.ts @@ -0,0 +1,50 @@ +import execa from 'execa'; +import walkSync from 'walk-sync'; +import { readFile, writeFile } from 'fs/promises'; + +export default function rollupDeclarationsPlugin(declarationsDir: string) { + let glintPromise: Promise; + + return { + name: 'glint-dts', + buildStart: () => { + const runGlint = async () => { + await execa('glint', ['--declaration'], { + stdio: 'inherit', + preferLocal: true, + }); + + await fixDeclarationsInMatchingFiles(declarationsDir); + }; + + // We just kick off glint here early in the rollup process, without making rollup wait for this to finish, by not returning the promise + // The output of this is not relevant to further stages of the rollup build, this is just happening in parallel to other rollup compilation + glintPromise = runGlint(); + }, + + // Make rollup wait for glint to have finished before calling the build job done + writeBundle: () => glintPromise, + }; +} + +async function fixDeclarationsInMatchingFiles(dir: string) { + const dtsFiles = walkSync(dir, { + globs: ['**/*.d.ts'], + directories: false, + includeBasePath: true, + }); + + return Promise.all( + dtsFiles.map(async (file) => { + const content = await readFile(file, { encoding: 'utf8' }); + + await writeFile(file, fixDeclarations(content)); + }) + ); +} + +// Strip any .gts extension from imports in d.ts files, as these won't resolve. See https://github.com/typed-ember/glint/issues/628 +// Once Glint v2 is available, this shouldn't be needed anymore. +function fixDeclarations(content: string) { + return content.replace(/from\s+['"]([^'"]+)\.gts['"]/g, `from '$1'`); +} diff --git a/packages/addon-dev/src/rollup.ts b/packages/addon-dev/src/rollup.ts index 3f83e2822..08d7db7ce 100644 --- a/packages/addon-dev/src/rollup.ts +++ b/packages/addon-dev/src/rollup.ts @@ -3,6 +3,7 @@ import { default as gjs } from './rollup-gjs-plugin'; import { default as publicEntrypoints } from './rollup-public-entrypoints'; import { default as appReexports } from './rollup-app-reexports'; import { default as keepAssets } from './rollup-keep-assets'; +import { default as declarations } from './rollup-declarations'; import { default as dependencies } from './rollup-addon-dependencies'; import { default as publicAssets, @@ -108,4 +109,8 @@ export class Addon { publicAssets(path: string, opts?: PublicAssetsOptions) { return publicAssets(path, opts); } + + declarations(path: string) { + return declarations(path); + } } diff --git a/packages/addon-dev/tests/declarations.test.ts b/packages/addon-dev/tests/declarations.test.ts new file mode 100644 index 000000000..e0391e4c1 --- /dev/null +++ b/packages/addon-dev/tests/declarations.test.ts @@ -0,0 +1,112 @@ +'use strict'; + +import rollupDeclarationsPlugin from '../src/rollup-declarations'; +import { Project } from 'scenario-tester'; +import { rollup } from 'rollup'; +import { readFile } from 'fs-extra'; +import { join } from 'path'; + +const projectBoilerplate = { + 'tsconfig.json': JSON.stringify({ + include: ['src/**/*'], + compilerOptions: { + declaration: true, + declarationDir: 'declarations', + emitDeclarationOnly: true, + rootDir: './src', + allowImportingTsExtensions: true, + }, + glint: { + environment: ['ember-loose', 'ember-template-imports'], + }, + }), +}; + +async function generateProject(src: {}): Promise { + const project = new Project('my-addon', { + files: { + ...projectBoilerplate, + src, + }, + }); + project.linkDevDependency('typescript', { baseDir: __dirname }); + project.linkDevDependency('@glint/core', { baseDir: __dirname }); + project.linkDevDependency('@glint/template', { baseDir: __dirname }); + project.linkDevDependency('@glint/environment-ember-loose', { + baseDir: __dirname, + }); + project.linkDevDependency('@glint/environment-ember-template-imports', { + baseDir: __dirname, + }); + + await project.write(); + + return project; +} + +async function runRollup(dir: string, rollupOptions = {}) { + const currentDir = process.cwd(); + process.chdir(dir); + + try { + const bundle = await rollup({ + input: './src/index.ts', + plugins: [rollupDeclarationsPlugin('declarations')], + ...rollupOptions, + }); + + await bundle.write({ format: 'esm', dir: 'dist' }); + } finally { + process.chdir(currentDir); + } +} + +describe('declarations', function () { + let project: Project | null; + + afterEach(() => { + project?.dispose(); + project = null; + }); + + test('it generates dts output', async function () { + project = await generateProject({ + 'index.ts': 'export default 123', + }); + + await runRollup(project.baseDir); + + expect( + await readFile(join(project.baseDir, 'declarations/index.d.ts'), { + encoding: 'utf8', + }) + ).toContain('export default'); + }); + + test('it has correct imports', async function () { + project = await generateProject({ + 'index.ts': ` + import foo from './foo.gts'; + import bar from './bar.gts'; + import baz from './baz.ts'; + export { foo, bar, baz }; + `, + 'foo.gts': 'export default 123', + 'bar.gts': 'export default 234', + 'baz.ts': 'export default 345', + }); + + await runRollup(project.baseDir); + + const output = await readFile( + join(project.baseDir, 'declarations/index.d.ts'), + { + encoding: 'utf8', + } + ); + + expect(output).toContain(`import foo from './foo';`); + expect(output).toContain(`import bar from './bar';`); + expect(output).toContain(`import baz from './baz.ts';`); + }); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c48bb6fc9..fa4e7518b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -66,6 +66,9 @@ importers: content-tag: specifier: ^3.0.0 version: 3.0.0 + execa: + specifier: ^5.1.1 + version: 5.1.1 fs-extra: specifier: ^10.0.0 version: 10.1.0 @@ -88,6 +91,18 @@ importers: '@glimmer/syntax': specifier: ^0.84.2 version: 0.84.3 + '@glint/core': + specifier: ^1.5.0 + version: 1.5.0(typescript@5.6.3) + '@glint/environment-ember-loose': + specifier: ^1.5.0 + version: 1.5.0(@glimmer/component@1.1.2)(@glint/template@1.5.0)(ember-cli-htmlbars@6.3.0)(ember-modifier@4.2.0) + '@glint/environment-ember-template-imports': + specifier: ^1.5.0 + version: 1.5.0(@glint/environment-ember-loose@1.5.0)(@glint/template@1.5.0) + '@glint/template': + specifier: ^1.5.0 + version: 1.5.0 '@types/fs-extra': specifier: ^9.0.12 version: 9.0.13 @@ -100,9 +115,9 @@ importers: rollup: specifier: ^3.23.0 version: 3.29.5 - tmp: - specifier: ^0.1.0 - version: 0.1.0 + scenario-tester: + specifier: ^4.0.0 + version: 4.1.1 typescript: specifier: ^5.4.5 version: 5.6.3 @@ -6960,6 +6975,26 @@ packages: '@glimmer/util': 0.92.3 dev: true + /@glint/core@1.5.0(typescript@5.6.3): + resolution: {integrity: sha512-oo6ZDwX2S0Qqjai/CJH72LHg1U6rvzH1IyiFlWofaFiu/nSg04CDWZuJNPC3r47jz1+SaSI+mVMUaKJznzxzzQ==} + hasBin: true + peerDependencies: + typescript: '>=4.8.0' + dependencies: + '@glimmer/syntax': 0.84.3 + escape-string-regexp: 4.0.0 + semver: 7.6.3 + silent-error: 1.1.1 + typescript: 5.6.3 + uuid: 8.3.2 + vscode-languageserver: 8.1.0 + vscode-languageserver-textdocument: 1.0.12 + vscode-uri: 3.0.8 + yargs: 17.7.2 + transitivePeerDependencies: + - supports-color + dev: true + /@glint/environment-ember-loose@1.5.0(@glimmer/component@1.1.2)(@glint/template@1.5.0)(ember-cli-htmlbars@6.3.0)(ember-modifier@4.2.0): resolution: {integrity: sha512-QCP4pVupq8zGcBmMDcEq9XI5lfrnklwNOIuzdXb8OnbcY6qpuwz5Y6VOsA1WNGRcip/5wwOsmI6gsAEUTlbvPQ==} peerDependencies: @@ -6994,6 +7029,30 @@ packages: ember-modifier: 4.2.0(@babel/core@7.26.0)(ember-source@5.3.0) dev: true + /@glint/environment-ember-template-imports@1.5.0(@glint/environment-ember-loose@1.5.0)(@glint/template@1.5.0): + resolution: {integrity: sha512-SS+KNffLuNYcsT7iEmCr2jp2538E7KTMEAWY+KWNvUJ0ZMd6oe6xbIIF50+9BgCgGHWwj7oL/NdgCVkS3OqRdw==} + peerDependencies: + '@glint/environment-ember-loose': ^1.5.0 + '@glint/template': ^1.5.0 + '@types/ember__component': ^4.0.10 + '@types/ember__helper': ^4.0.1 + '@types/ember__modifier': ^4.0.3 + '@types/ember__routing': ^4.0.12 + peerDependenciesMeta: + '@types/ember__component': + optional: true + '@types/ember__helper': + optional: true + '@types/ember__modifier': + optional: true + '@types/ember__routing': + optional: true + dependencies: + '@glint/environment-ember-loose': 1.5.0(@glimmer/component@1.1.2)(@glint/template@1.5.0)(ember-cli-htmlbars@6.3.0)(ember-modifier@4.2.0) + '@glint/template': 1.5.0 + content-tag: 2.0.2 + dev: true + /@glint/template@1.5.0: resolution: {integrity: sha512-KyQUCWifxl8wDxo3SXzJcGKttHbIPgFBtqsoiu13Edx/o4CgGXr5rrM64jJR7Wvunn8sRM+Rq7Y0cHoB068Wuw==} @@ -25081,6 +25140,37 @@ packages: fsevents: 2.3.3 dev: true + /vscode-jsonrpc@8.1.0: + resolution: {integrity: sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==} + engines: {node: '>=14.0.0'} + dev: true + + /vscode-languageserver-protocol@3.17.3: + resolution: {integrity: sha512-924/h0AqsMtA5yK22GgMtCYiMdCOtWTSGgUOkgEDX+wk2b0x4sAfLiO4NxBxqbiVtz7K7/1/RgVrVI0NClZwqA==} + dependencies: + vscode-jsonrpc: 8.1.0 + vscode-languageserver-types: 3.17.3 + dev: true + + /vscode-languageserver-textdocument@1.0.12: + resolution: {integrity: sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==} + dev: true + + /vscode-languageserver-types@3.17.3: + resolution: {integrity: sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==} + dev: true + + /vscode-languageserver@8.1.0: + resolution: {integrity: sha512-eUt8f1z2N2IEUDBsKaNapkz7jl5QpskN2Y0G01T/ItMxBxw1fJwvtySGB9QMecatne8jFIWJGWI61dWjyTLQsw==} + hasBin: true + dependencies: + vscode-languageserver-protocol: 3.17.3 + dev: true + + /vscode-uri@3.0.8: + resolution: {integrity: sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==} + dev: true + /w3c-hr-time@1.0.2: resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==} deprecated: Use your platform's native performance.now() and performance.timeOrigin. From 2be6e7b2ddf3ad0365fd87c2ac8173e1f5ba4680 Mon Sep 17 00:00:00 2001 From: simonihmig <1325249+simonihmig@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:09:41 +0000 Subject: [PATCH 12/12] Prepare Release using 'release-plan' --- .release-plan.json | 45 ++++++++++++++++++++++++++------- CHANGELOG.md | 20 +++++++++++++++ packages/addon-dev/package.json | 2 +- packages/compat/package.json | 2 +- packages/core/package.json | 2 +- packages/macros/package.json | 2 +- 6 files changed, 60 insertions(+), 13 deletions(-) diff --git a/.release-plan.json b/.release-plan.json index c6cf68bf4..6dc2aeba6 100644 --- a/.release-plan.json +++ b/.release-plan.json @@ -1,13 +1,13 @@ { "solution": { "@embroider/addon-dev": { - "impact": "major", - "oldVersion": "6.0.1", - "newVersion": "7.0.0", + "impact": "minor", + "oldVersion": "7.0.0", + "newVersion": "7.1.0", "constraints": [ { - "impact": "major", - "reason": "Appears in changelog section :boom: Breaking Change" + "impact": "minor", + "reason": "Appears in changelog section :rocket: Enhancement" } ], "pkgJSONPath": "./packages/addon-dev/package.json" @@ -22,16 +22,43 @@ "oldVersion": "1.0.1" }, "@embroider/compat": { - "oldVersion": "3.7.0" + "impact": "patch", + "oldVersion": "3.7.0", + "newVersion": "3.7.1", + "constraints": [ + { + "impact": "patch", + "reason": "Has dependency `workspace:*` on @embroider/macros" + } + ], + "pkgJSONPath": "./packages/compat/package.json" }, "@embroider/core": { - "oldVersion": "3.4.19" + "impact": "patch", + "oldVersion": "3.4.19", + "newVersion": "3.4.20", + "constraints": [ + { + "impact": "patch", + "reason": "Has dependency `workspace:*` on @embroider/macros" + } + ], + "pkgJSONPath": "./packages/core/package.json" }, "@embroider/hbs-loader": { "oldVersion": "3.0.3" }, "@embroider/macros": { - "oldVersion": "1.16.9" + "impact": "patch", + "oldVersion": "1.16.9", + "newVersion": "1.16.10", + "constraints": [ + { + "impact": "patch", + "reason": "Appears in changelog section :house: Internal" + } + ], + "pkgJSONPath": "./packages/macros/package.json" }, "@embroider/reverse-exports": { "oldVersion": "0.1.0" @@ -55,5 +82,5 @@ "oldVersion": "4.0.8" } }, - "description": "## Release (2024-11-11)\n\n@embroider/addon-dev 7.0.0 (major)\n\n#### :boom: Breaking Change\n* `@embroider/addon-dev`\n * [#2166](https://github.com/embroider-build/embroider/pull/2166) Fix gjs/gts sourcemaps -- we accidentally unlocked really good DX ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n\n#### Committers: 1\n- [@NullVoxPopuli](https://github.com/NullVoxPopuli)\n" + "description": "## Release (2024-12-16)\n\n@embroider/addon-dev 7.1.0 (minor)\n@embroider/compat 3.7.1 (patch)\n@embroider/core 3.4.20 (patch)\n@embroider/macros 1.16.10 (patch)\n\n#### :rocket: Enhancement\n* `@embroider/addon-dev`\n * [#2200](https://github.com/embroider-build/embroider/pull/2200) Add rollup declarations plugin ([@simonihmig](https://github.com/simonihmig))\n\n#### :house: Internal\n* `@embroider/sample-transforms`, `@embroider/test-fixtures`, `@embroider/test-scenarios`\n * [#2204](https://github.com/embroider-build/embroider/pull/2204) Fix stable ([@simonihmig](https://github.com/simonihmig))\n* `@embroider/macros`\n * [#2201](https://github.com/embroider-build/embroider/pull/2201) Fix type error on stable ([@simonihmig](https://github.com/simonihmig))\n\n#### Committers: 1\n- Simon Ihmig ([@simonihmig](https://github.com/simonihmig))\n" } diff --git a/CHANGELOG.md b/CHANGELOG.md index c743b8d00..f41cc1686 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Embroider Changelog +## Release (2024-12-16) + +@embroider/addon-dev 7.1.0 (minor) +@embroider/compat 3.7.1 (patch) +@embroider/core 3.4.20 (patch) +@embroider/macros 1.16.10 (patch) + +#### :rocket: Enhancement +* `@embroider/addon-dev` + * [#2200](https://github.com/embroider-build/embroider/pull/2200) Add rollup declarations plugin ([@simonihmig](https://github.com/simonihmig)) + +#### :house: Internal +* `@embroider/sample-transforms`, `@embroider/test-fixtures`, `@embroider/test-scenarios` + * [#2204](https://github.com/embroider-build/embroider/pull/2204) Fix stable ([@simonihmig](https://github.com/simonihmig)) +* `@embroider/macros` + * [#2201](https://github.com/embroider-build/embroider/pull/2201) Fix type error on stable ([@simonihmig](https://github.com/simonihmig)) + +#### Committers: 1 +- Simon Ihmig ([@simonihmig](https://github.com/simonihmig)) + ## Release (2024-11-11) @embroider/addon-dev 7.0.0 (major) diff --git a/packages/addon-dev/package.json b/packages/addon-dev/package.json index b08385c3a..5fe35e03b 100644 --- a/packages/addon-dev/package.json +++ b/packages/addon-dev/package.json @@ -1,6 +1,6 @@ { "name": "@embroider/addon-dev", - "version": "7.0.0", + "version": "7.1.0", "description": "Utilities for addon authors", "repository": { "type": "git", diff --git a/packages/compat/package.json b/packages/compat/package.json index 505339cf5..bffcd4a71 100644 --- a/packages/compat/package.json +++ b/packages/compat/package.json @@ -1,6 +1,6 @@ { "name": "@embroider/compat", - "version": "3.7.0", + "version": "3.7.1", "private": false, "description": "Backward compatibility layer for the Embroider build system.", "repository": { diff --git a/packages/core/package.json b/packages/core/package.json index 32614b34c..e98ea0464 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@embroider/core", - "version": "3.4.19", + "version": "3.4.20", "private": false, "description": "A build system for EmberJS applications.", "repository": { diff --git a/packages/macros/package.json b/packages/macros/package.json index 655c4a113..8ab2ed3b4 100644 --- a/packages/macros/package.json +++ b/packages/macros/package.json @@ -1,6 +1,6 @@ { "name": "@embroider/macros", - "version": "1.16.9", + "version": "1.16.10", "private": false, "description": "Standardized build-time macros for ember apps.", "keywords": [