diff --git a/packages/vite/src/esbuild-request.ts b/packages/vite/src/esbuild-request.ts index f2f25e0dd..d9c028430 100644 --- a/packages/vite/src/esbuild-request.ts +++ b/packages/vite/src/esbuild-request.ts @@ -12,7 +12,7 @@ type PackageCache = PublicAPI<_PackageCache>; export class EsBuildModuleRequest implements ModuleRequest { static from( packageCache: PackageCache, - phase: 'bundling' | 'scanning', + phase: 'bundling' | 'other', context: PluginBuild, kind: ImportKind, source: string, @@ -42,7 +42,7 @@ export class EsBuildModuleRequest implements ModuleRequest { private constructor( private packageCache: PackageCache, - private phase: 'bundling' | 'scanning', + private phase: 'bundling' | 'other', private context: PluginBuild, private kind: ImportKind, readonly specifier: string, diff --git a/packages/vite/src/esbuild-resolver.ts b/packages/vite/src/esbuild-resolver.ts index ace8d1db4..e3ee2bc20 100644 --- a/packages/vite/src/esbuild-resolver.ts +++ b/packages/vite/src/esbuild-resolver.ts @@ -153,14 +153,12 @@ export function esBuildResolver(): EsBuildPlugin { }; } -function detectPhase(build: PluginBuild): 'bundling' | 'scanning' { +function detectPhase(build: PluginBuild): 'bundling' | 'other' { let plugins = (build.initialOptions.plugins ?? []).map(p => p.name); if (plugins.includes('vite:dep-pre-bundle')) { return 'bundling'; - } else if (plugins.includes('vite:dep-scan')) { - return 'scanning'; } else { - throw new Error(`cannot identify what phase vite is in. Saw plugins: ${plugins.join(', ')}`); + return 'other'; } } diff --git a/tests/scenarios/vite-internals-test.ts b/tests/scenarios/vite-internals-test.ts index 60cb58542..765e1ab9b 100644 --- a/tests/scenarios/vite-internals-test.ts +++ b/tests/scenarios/vite-internals-test.ts @@ -76,6 +76,12 @@ appScenarios `, 'epsilon.hbs': `
Epsilon
`, 'fancy-button.hbs': `

I'm fancy

`, + 'delta.js': ` + import Component from '@glimmer/component'; + export default class extends Component { + message = "delta"; + } + `, }, templates: { 'application.hbs': ` @@ -136,6 +142,11 @@ appScenarios assert.dom('.epsilon').hasText('Epsilon'); }); + test("paired component between app and addon", async function (assert) { + await render(hbs\`\`); + assert.dom('.delta').hasText('delta'); + }); + test("addon depends on an app's module via relative import", async function (assert) { assert.strictEqual(appLibOne(), libOneViaAddon(), 'lib one works the same'); assert.strictEqual(globalThis.appLibOneLoaded, 1, 'app lib one loaded once'); @@ -179,6 +190,13 @@ appScenarios import appLibTwo from 'app-template/lib/app-lib-two'; export { appLibOne, appLibTwo }; `, + templates: { + components: { + 'delta.hbs': ` +
delta
+ `, + }, + }, components: { 'beta.js': ` export { default } from 'v1-example-addon/components/beta';