Skip to content

Commit

Permalink
fix vite build
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Feb 14, 2024
1 parent 43da932 commit 106b7e1
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 100 deletions.
6 changes: 5 additions & 1 deletion packages/vite/src/hbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export function hbs(): Plugin {
return {
name: 'rollup-hbs-plugin',
enforce: 'pre',
async resolveId(source: string, importer: string | undefined) {
async resolveId(source: string, importer: string | undefined, options) {
if (options.custom?.embroider?.isExtensionSearch) {
return null;
}
let resolution = await this.resolve(source, importer, {
skipSelf: true,
});
Expand Down Expand Up @@ -89,6 +92,7 @@ async function maybeSynthesizeComponentJS(context: PluginContext, source: string
// Currently this guard is only actually exercised in rollup, not in
// vite, due to https://github.com/vitejs/vite/issues/13852
enableCustomResolver: false,
isExtensionSearch: true,
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function resolver(): Plugin {
if (id.startsWith(virtualPrefix)) {
let { src, watches } = virtualContent(id.slice(virtualPrefix.length), resolverLoader.resolver);
virtualDeps.set(id, watches);
server.watcher.add(watches);
server?.watcher.add(watches);
return src;
}
},
Expand Down
6 changes: 5 additions & 1 deletion packages/vite/src/template-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export function templateTag({ inline_source_map } = { inline_source_map: false }
name: 'embroider-template-tag',
enforce: 'pre',

async resolveId(id: string, importer: string | undefined) {
async resolveId(id: string, importer: string | undefined, options) {
if (options.custom?.embroider?.isExtensionSearch) {
return null;
}
let resolution = await this.resolve(id, importer, {
skipSelf: true,
});
Expand All @@ -27,6 +30,7 @@ export function templateTag({ inline_source_map } = { inline_source_map: false }
skipSelf: true,
custom: {
embroider: {
isExtensionSearch: true,
enableCustomResolver: false,
},
},
Expand Down
Loading

0 comments on commit 106b7e1

Please sign in to comment.