Go back to ESM
This commit is contained in:
parent
530b77ed0a
commit
8f67687eef
6 changed files with 36 additions and 5 deletions
4
examples/cool-app/astro.config.mjs
Normal file
4
examples/cool-app/astro.config.mjs
Normal file
|
@ -0,0 +1,4 @@
|
|||
// @ts-check
|
||||
export default /** @type {import('astro').AstroUserConfig} */ ({
|
||||
renderers: [],
|
||||
});
|
14
examples/cool-app/package.json
Normal file
14
examples/cool-app/package.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "@example/cool-app",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"start": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"astro": "^0.21.6"
|
||||
}
|
||||
}
|
BIN
examples/cool-app/src/images/penguin.jpg
Normal file
BIN
examples/cool-app/src/images/penguin.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
13
examples/cool-app/src/pages/index.astro
Normal file
13
examples/cool-app/src/pages/index.astro
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
import imgUrl from '../images/penguin.jpg';
|
||||
---
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Demo app</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Penguins are cool</h1>
|
||||
<img src={imgUrl} />
|
||||
</body>
|
||||
</html>
|
|
@ -180,7 +180,7 @@ class AstroBuilder {
|
|||
// The `input` will be populated in the build rollup plugin.
|
||||
input: [],
|
||||
output: {
|
||||
format: 'cjs'
|
||||
format: 'esm'
|
||||
},
|
||||
},
|
||||
target: 'es2020', // must match an esbuild target
|
||||
|
@ -255,7 +255,7 @@ class AstroBuilder {
|
|||
let url = new URL('./' + out.fileName, this.config.dist);
|
||||
let pageData = facadeIdToPageDataMap.get(out.facadeModuleId)!;
|
||||
let compiledModule = await import(url.toString());
|
||||
let Component = compiledModule.default.default;
|
||||
let Component = compiledModule.default;
|
||||
|
||||
const [renderers, mod] = pageData.preload;
|
||||
|
||||
|
|
|
@ -243,12 +243,12 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin {
|
|||
if (!pageName) {
|
||||
pageName = 'index';
|
||||
}
|
||||
return `assets/${pageName}.[hash].cjs`;
|
||||
return `assets/${pageName}.[hash].mjs`;
|
||||
}
|
||||
return 'assets/[name].[hash].cjs';
|
||||
return 'assets/[name].[hash].mjs';
|
||||
},
|
||||
chunkFileNames(chunk: PreRenderedChunk) {
|
||||
return 'assets/[name].[hash].cjs';
|
||||
return 'assets/[name].[hash].mjs';
|
||||
}
|
||||
});
|
||||
return outputOptions;
|
||||
|
|
Loading…
Add table
Reference in a new issue