Export astro/compiler-runtime and cleanup exports (#8085)

This commit is contained in:
Bjorn Lu 2023-08-15 16:21:28 +08:00 committed by GitHub
parent 7b77b34cef
commit 68efd4a8b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 6 deletions

View file

@ -0,0 +1,25 @@
---
'astro': major
---
Remove exports for `astro/internal/*` and `astro/runtime/server/*` in favour of `astro/runtime/*`. Add new `astro/compiler-runtime` export for compiler-specific runtime code.
These are exports for Astro's internal API and should not affect your project, but if you do use these entrypoints, you can migrate like below:
```diff
- import 'astro/internal/index.js';
+ import 'astro/runtime/server/index.js';
- import 'astro/server/index.js';
+ import 'astro/runtime/server/index.js';
```
```diff
import { transform } from '@astrojs/compiler';
const result = await transform(source, {
- internalURL: 'astro/runtime/server/index.js',
+ internalURL: 'astro/compiler-runtime',
// ...
});
```

View file

@ -42,6 +42,8 @@
"./tsconfigs/*": "./tsconfigs/*.json",
"./jsx/*": "./dist/jsx/*",
"./jsx-runtime": "./dist/jsx-runtime/index.js",
"./compiler-runtime": "./dist/runtime/compiler/index.js",
"./runtime/*": "./dist/runtime/*",
"./config": {
"types": "./config.d.ts",
"default": "./config.mjs"
@ -60,10 +62,7 @@
"./content/runtime": "./dist/content/runtime.js",
"./content/runtime-assets": "./dist/content/runtime-assets.js",
"./debug": "./components/Debug.astro",
"./internal/*": "./dist/runtime/server/*",
"./package.json": "./package.json",
"./runtime/*": "./dist/runtime/*",
"./server/*": "./dist/runtime/server/*",
"./zod": {
"types": "./zod.d.ts",
"default": "./zod.mjs"

View file

@ -41,7 +41,7 @@ export async function compile({
filename,
normalizedFilename: normalizeFilename(filename, astroConfig.root),
sourcemap: 'both',
internalURL: 'astro/server/index.js',
internalURL: 'astro/compiler-runtime',
astroGlobalArgs: JSON.stringify(astroConfig.site),
scopedStyleStrategy: astroConfig.scopedStyleStrategy,
resultScopedSlot: true,

View file

@ -4,5 +4,6 @@ Code that executes within isolated contexts:
- `client/`: executes within the browser. Astros client-side partial hydration code lives here, and only browser-compatible code can be used.
- `server/`: executes inside Vite SSR. Though also a Node context, this is isolated from code in `core/`.
- `compiler/`: same as `server/`, but only used by the Astro compiler `internalURL` option.
[See CONTRIBUTING.md](../../../../CONTRIBUTING.md) for a code overview.

View file

@ -0,0 +1,20 @@
// NOTE: Although this entrypoint is exported, it is internal API and may change at any time.
export {
Fragment,
render,
createAstro,
createComponent,
renderComponent,
renderHead,
maybeRenderHead,
unescapeHTML,
renderSlot,
mergeSlots,
addAttribute,
renderTransition,
createTransitionScope,
spreadAttributes,
defineStyleVars,
defineScriptVars,
} from '../server/index.js';

View file

@ -1,3 +1,5 @@
// NOTE: Although this entrypoint is exported, it is internal API and may change at any time.
export { createComponent } from './astro-component.js';
export { createAstro } from './astro-global.js';
export { renderEndpoint } from './endpoint.js';

View file

@ -18,7 +18,7 @@ export default async function tagExportsWithRenderer({
return {
visitor: {
Program: {
// Inject `import { __astro_tag_component__ } from 'astro/server/index.js'`
// Inject `import { __astro_tag_component__ } from 'astro/runtime/server/index.js'`
enter(path) {
path.node.body.splice(
0,
@ -30,7 +30,7 @@ export default async function tagExportsWithRenderer({
t.identifier('__astro_tag_component__')
),
],
t.stringLiteral('astro/server/index.js')
t.stringLiteral('astro/runtime/server/index.js')
)
);
},