diff options
author | 2021-03-31 16:46:09 -0400 | |
---|---|---|
committer | 2021-03-31 16:46:09 -0400 | |
commit | d5b15a385153915cad7dbffd0d8893c39059c1ed (patch) | |
tree | 769240e3f6e52c31639f0500d97b87e45f202a6a /src/build.ts | |
parent | d9084ff4ad9e25577846d3eb53046c2f0066097f (diff) | |
download | astro-d5b15a385153915cad7dbffd0d8893c39059c1ed.tar.gz astro-d5b15a385153915cad7dbffd0d8893c39059c1ed.tar.zst astro-d5b15a385153915cad7dbffd0d8893c39059c1ed.zip |
Support for custom elements (#45)
* Support for custom elements
Now you can use custom elements like so in Astro components:
```html
<script type="module" src="./datepicker.js">
<date-picker></date-picker>
```
These will be resolve relative to the current astro component. In the build these modules are run through the same bundle/minify process as components.
* Remove component from public
* Formatting
* Disable empty fn rule
Diffstat (limited to '')
-rw-r--r-- | src/build.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/build.ts b/src/build.ts index ffae6fac0..7f4fa713c 100644 --- a/src/build.ts +++ b/src/build.ts @@ -52,6 +52,7 @@ async function writeResult(result: LoadResult, outPath: URL, encoding: null | 'u export async function build(astroConfig: AstroConfig): Promise<0 | 1> { const { projectRoot, astroRoot } = astroConfig; const pageRoot = new URL('./pages/', astroRoot); + const componentRoot = new URL('./components/', astroRoot); const dist = new URL(astroConfig.dist + '/', projectRoot); const runtimeLogging: LogOptions = { @@ -66,6 +67,7 @@ export async function build(astroConfig: AstroConfig): Promise<0 | 1> { const imports = new Set<string>(); const statics = new Set<string>(); + const collectImportsOptions = { astroConfig, logging, resolve }; for (const pathname of await allPages(pageRoot)) { const filepath = new URL(`file://${pathname}`); @@ -90,7 +92,11 @@ export async function build(astroConfig: AstroConfig): Promise<0 | 1> { return 1; } - mergeSet(imports, await collectDynamicImports(filepath, astroConfig, resolve)); + mergeSet(imports, await collectDynamicImports(filepath, collectImportsOptions)); + } + + for (const pathname of await allPages(componentRoot)) { + mergeSet(imports, await collectDynamicImports(new URL(`file://${pathname}`), collectImportsOptions)); } await bundle(imports, { dist, runtime, astroConfig }); |