Skip to content

Commit

Permalink
Merge pull request #2053 from embroider-build/verify-default-app-vite
Browse files Browse the repository at this point in the history
fix for esbuild finding helpers and components from app-tree-merging in templates
  • Loading branch information
mansona committed Jul 17, 2024
2 parents 0b5db9f + dc9a396 commit 324f52a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
9 changes: 8 additions & 1 deletion packages/core/src/module-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,10 @@ export class Resolver {
})
);

if (resolution.type === 'ignored') {
return logTransition(`resolving to ignored component`, request, request.resolveTo(resolution));
}

// .hbs is a resolvable extension for us, so we need to exclude it here.
// It matches as a priority lower than .js, so finding an .hbs means
// there's definitely not a .js.
Expand Down Expand Up @@ -702,7 +706,10 @@ export class Resolver {
})
);

if (helperMatch.type === 'found') {
// for the case of 'ignored' that means that esbuild found this helper in an external
// package so it should be considered found in this case and we should not look for a
// component with this name
if (helperMatch.type === 'found' || helperMatch.type === 'ignored') {
return logTransition('resolve to ambiguous case matched a helper', request, request.resolveTo(helperMatch));
}

Expand Down
30 changes: 29 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/scenarios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"ember-engines": "^0.8.23",
"ember-inline-svg": "^0.2.1",
"ember-modifier": "^4.0.0",
"ember-page-title": "^8.2.3",
"ember-qunit-7": "npm:ember-qunit@^7.0.0",
"ember-source": "~3.28.11",
"ember-source-4.12": "npm:ember-source@~4.12.0",
Expand All @@ -93,8 +94,9 @@
"ember-source-beta": "npm:ember-source@beta",
"ember-source-canary": "https://s3.amazonaws.com/builds.emberjs.com/canary/shas/370cf34f9e86df17b880f11fef35a5a0f24ff38a.tgz",
"ember-source-latest": "npm:ember-source@latest",
"ember-truth-helpers": "^3.0.0",
"ember-test-helpers-2": "npm:@ember/test-helpers@^2.0.0",
"ember-truth-helpers": "^3.0.0",
"ember-welcome-page": "^7.0.2",
"execa": "^5.1.1",
"node-fetch": "2.7.0",
"popper.js": "^1.16.1",
Expand Down
9 changes: 8 additions & 1 deletion tests/scenarios/vite-internals-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ const { module: Qmodule, test } = QUnit;
appScenarios
.only('canary')
.map('vite-internals', app => {
app.linkDevDependency('ember-page-title', { baseDir: __dirname });
app.linkDevDependency('ember-welcome-page', { baseDir: __dirname });
app.mergeFiles({
app: {
components: {
'fancy-button.hbs': `<h1>I'm fancy</h1>`,
},
templates: {
'application.hbs': '<FancyButton />',
'application.hbs': `{{page-title "MyApp"}}
<FancyButton />
{{outlet}}
<WelcomePage />`,
},
},
});
Expand Down

0 comments on commit 324f52a

Please sign in to comment.