Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,26 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
expect(await response?.status).toBe(301);
expect(await response?.headers.get('Location')).toBe('/login/');
});

it('serves a JavaScript asset named as a bundle', async () => {
await harness.writeFile('public/test/main.js', javascriptFileContent);

setupTarget(harness, {
assets: [
{
glob: '**/*',
input: 'public',
},
],
});

harness.useTarget('serve', {
...BASE_OPTIONS,
});

const { result, response } = await executeOnceAndFetch(harness, 'test/main.js');
expect(result?.success).toBeTrue();
expect(await response?.text()).toContain(javascriptFileContent);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface AngularMemoryPluginOptions {
}

const ANGULAR_PREFIX = '/@ng/';
const VITE_FS_PREFIX = '/@fs/';

export async function createAngularMemoryPlugin(
options: AngularMemoryPluginOptions,
Expand All @@ -34,6 +35,10 @@ export async function createAngularMemoryPlugin(
// Ensures plugin hooks run before built-in Vite hooks
enforce: 'pre',
async resolveId(source, importer, { ssr }) {
if (source.startsWith(VITE_FS_PREFIX)) {
return;
}

// For SSR with component HMR, pass through as a virtual module
if (ssr && source.startsWith(ANGULAR_PREFIX)) {
return '\0' + source;
Expand Down
Loading