Export astro/compiler-runtime and cleanup exports (#8085)
This commit is contained in:
parent
7b77b34cef
commit
68efd4a8b2
7 changed files with 53 additions and 6 deletions
25
.changeset/neat-owls-run.md
Normal file
25
.changeset/neat-owls-run.md
Normal 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',
|
||||||
|
// ...
|
||||||
|
});
|
||||||
|
```
|
|
@ -42,6 +42,8 @@
|
||||||
"./tsconfigs/*": "./tsconfigs/*.json",
|
"./tsconfigs/*": "./tsconfigs/*.json",
|
||||||
"./jsx/*": "./dist/jsx/*",
|
"./jsx/*": "./dist/jsx/*",
|
||||||
"./jsx-runtime": "./dist/jsx-runtime/index.js",
|
"./jsx-runtime": "./dist/jsx-runtime/index.js",
|
||||||
|
"./compiler-runtime": "./dist/runtime/compiler/index.js",
|
||||||
|
"./runtime/*": "./dist/runtime/*",
|
||||||
"./config": {
|
"./config": {
|
||||||
"types": "./config.d.ts",
|
"types": "./config.d.ts",
|
||||||
"default": "./config.mjs"
|
"default": "./config.mjs"
|
||||||
|
@ -60,10 +62,7 @@
|
||||||
"./content/runtime": "./dist/content/runtime.js",
|
"./content/runtime": "./dist/content/runtime.js",
|
||||||
"./content/runtime-assets": "./dist/content/runtime-assets.js",
|
"./content/runtime-assets": "./dist/content/runtime-assets.js",
|
||||||
"./debug": "./components/Debug.astro",
|
"./debug": "./components/Debug.astro",
|
||||||
"./internal/*": "./dist/runtime/server/*",
|
|
||||||
"./package.json": "./package.json",
|
"./package.json": "./package.json",
|
||||||
"./runtime/*": "./dist/runtime/*",
|
|
||||||
"./server/*": "./dist/runtime/server/*",
|
|
||||||
"./zod": {
|
"./zod": {
|
||||||
"types": "./zod.d.ts",
|
"types": "./zod.d.ts",
|
||||||
"default": "./zod.mjs"
|
"default": "./zod.mjs"
|
||||||
|
|
|
@ -41,7 +41,7 @@ export async function compile({
|
||||||
filename,
|
filename,
|
||||||
normalizedFilename: normalizeFilename(filename, astroConfig.root),
|
normalizedFilename: normalizeFilename(filename, astroConfig.root),
|
||||||
sourcemap: 'both',
|
sourcemap: 'both',
|
||||||
internalURL: 'astro/server/index.js',
|
internalURL: 'astro/compiler-runtime',
|
||||||
astroGlobalArgs: JSON.stringify(astroConfig.site),
|
astroGlobalArgs: JSON.stringify(astroConfig.site),
|
||||||
scopedStyleStrategy: astroConfig.scopedStyleStrategy,
|
scopedStyleStrategy: astroConfig.scopedStyleStrategy,
|
||||||
resultScopedSlot: true,
|
resultScopedSlot: true,
|
||||||
|
|
|
@ -4,5 +4,6 @@ Code that executes within isolated contexts:
|
||||||
|
|
||||||
- `client/`: executes within the browser. Astro’s client-side partial hydration code lives here, and only browser-compatible code can be used.
|
- `client/`: executes within the browser. Astro’s 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/`.
|
- `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.
|
[See CONTRIBUTING.md](../../../../CONTRIBUTING.md) for a code overview.
|
||||||
|
|
20
packages/astro/src/runtime/compiler/index.ts
Normal file
20
packages/astro/src/runtime/compiler/index.ts
Normal 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';
|
|
@ -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 { createComponent } from './astro-component.js';
|
||||||
export { createAstro } from './astro-global.js';
|
export { createAstro } from './astro-global.js';
|
||||||
export { renderEndpoint } from './endpoint.js';
|
export { renderEndpoint } from './endpoint.js';
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default async function tagExportsWithRenderer({
|
||||||
return {
|
return {
|
||||||
visitor: {
|
visitor: {
|
||||||
Program: {
|
Program: {
|
||||||
// Inject `import { __astro_tag_component__ } from 'astro/server/index.js'`
|
// Inject `import { __astro_tag_component__ } from 'astro/runtime/server/index.js'`
|
||||||
enter(path) {
|
enter(path) {
|
||||||
path.node.body.splice(
|
path.node.body.splice(
|
||||||
0,
|
0,
|
||||||
|
@ -30,7 +30,7 @@ export default async function tagExportsWithRenderer({
|
||||||
t.identifier('__astro_tag_component__')
|
t.identifier('__astro_tag_component__')
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
t.stringLiteral('astro/server/index.js')
|
t.stringLiteral('astro/runtime/server/index.js')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue