forked from laptou/astro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-enable custom element test and fix "undefined" child (withastro#3095)
* Re-enable custom element test and fix "undefined" child * Remove outdated comment * Adds a changeset
- Loading branch information
Showing
6 changed files
with
55 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import ceIntegration from '@test/custom-element-renderer'; | ||
|
||
export default defineConfig({ | ||
integrations: [ceIntegration()], | ||
experimental: { | ||
integrations: true | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
export default { | ||
name: '@test/custom-element-renderer', | ||
server: './server.js', | ||
polyfills: [ | ||
'./polyfill.js' | ||
], | ||
hydrationPolyfills: [ | ||
'./hydration-polyfill.js' | ||
], | ||
viteConfig() { | ||
return { | ||
optimizeDeps: { | ||
include: ['@test/custom-element-renderer/polyfill.js', '@test/custom-element-renderer/hydration-polyfill.js'], | ||
exclude: ['@test/custom-element-renderer/server.js'] | ||
} | ||
} | ||
} | ||
}; | ||
function getViteConfiguration() { | ||
return { | ||
optimizeDeps: { | ||
include: ['@test/custom-element-renderer/polyfill.js', '@test/custom-element-renderer/hydration-polyfill.js'], | ||
exclude: ['@test/custom-element-renderer/server.js'] | ||
}, | ||
}; | ||
} | ||
|
||
export default function () { | ||
return { | ||
name: '@test/custom-element-renderer', | ||
hooks: { | ||
'astro:config:setup': ({ updateConfig, addRenderer, injectScript }) => { | ||
// Inject the necessary polyfills on every page | ||
injectScript('head-inline', `import '@test/custom-element-renderer/polyfill.js';`); | ||
// Inject the hydration code, before a component is hydrated. | ||
injectScript('before-hydration', `import '@test/custom-element-renderer/hydration-polyfill.js';`); | ||
// Add the lit renderer so that Astro can understand lit components. | ||
addRenderer({ | ||
name: '@test/custom-element-renderer', | ||
serverEntrypoint: '@test/custom-element-renderer/server.js', | ||
}); | ||
// Update the vite configuration. | ||
updateConfig({ | ||
vite: getViteConfiguration(), | ||
}); | ||
}, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters