Skip to content

Commit 68efd4a

Browse files
authored
Export astro/compiler-runtime and cleanup exports (#8085)
1 parent 7b77b34 commit 68efd4a

7 files changed

Lines changed: 53 additions & 6 deletions

File tree

.changeset/neat-owls-run.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'astro': major
3+
---
4+
5+
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.
6+
7+
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:
8+
9+
```diff
10+
- import 'astro/internal/index.js';
11+
+ import 'astro/runtime/server/index.js';
12+
13+
- import 'astro/server/index.js';
14+
+ import 'astro/runtime/server/index.js';
15+
```
16+
17+
```diff
18+
import { transform } from '@astrojs/compiler';
19+
20+
const result = await transform(source, {
21+
- internalURL: 'astro/runtime/server/index.js',
22+
+ internalURL: 'astro/compiler-runtime',
23+
// ...
24+
});
25+
```

packages/astro/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
"./tsconfigs/*": "./tsconfigs/*.json",
4343
"./jsx/*": "./dist/jsx/*",
4444
"./jsx-runtime": "./dist/jsx-runtime/index.js",
45+
"./compiler-runtime": "./dist/runtime/compiler/index.js",
46+
"./runtime/*": "./dist/runtime/*",
4547
"./config": {
4648
"types": "./config.d.ts",
4749
"default": "./config.mjs"
@@ -60,10 +62,7 @@
6062
"./content/runtime": "./dist/content/runtime.js",
6163
"./content/runtime-assets": "./dist/content/runtime-assets.js",
6264
"./debug": "./components/Debug.astro",
63-
"./internal/*": "./dist/runtime/server/*",
6465
"./package.json": "./package.json",
65-
"./runtime/*": "./dist/runtime/*",
66-
"./server/*": "./dist/runtime/server/*",
6766
"./zod": {
6867
"types": "./zod.d.ts",
6968
"default": "./zod.mjs"

packages/astro/src/core/compile/compile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function compile({
4141
filename,
4242
normalizedFilename: normalizeFilename(filename, astroConfig.root),
4343
sourcemap: 'both',
44-
internalURL: 'astro/server/index.js',
44+
internalURL: 'astro/compiler-runtime',
4545
astroGlobalArgs: JSON.stringify(astroConfig.site),
4646
scopedStyleStrategy: astroConfig.scopedStyleStrategy,
4747
resultScopedSlot: true,

packages/astro/src/runtime/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ Code that executes within isolated contexts:
44

55
- `client/`: executes within the browser. Astro’s client-side partial hydration code lives here, and only browser-compatible code can be used.
66
- `server/`: executes inside Vite SSR. Though also a Node context, this is isolated from code in `core/`.
7+
- `compiler/`: same as `server/`, but only used by the Astro compiler `internalURL` option.
78

89
[See CONTRIBUTING.md](../../../../CONTRIBUTING.md) for a code overview.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// NOTE: Although this entrypoint is exported, it is internal API and may change at any time.
2+
3+
export {
4+
Fragment,
5+
render,
6+
createAstro,
7+
createComponent,
8+
renderComponent,
9+
renderHead,
10+
maybeRenderHead,
11+
unescapeHTML,
12+
renderSlot,
13+
mergeSlots,
14+
addAttribute,
15+
renderTransition,
16+
createTransitionScope,
17+
spreadAttributes,
18+
defineStyleVars,
19+
defineScriptVars,
20+
} from '../server/index.js';

packages/astro/src/runtime/server/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// NOTE: Although this entrypoint is exported, it is internal API and may change at any time.
2+
13
export { createComponent } from './astro-component.js';
24
export { createAstro } from './astro-global.js';
35
export { renderEndpoint } from './endpoint.js';

packages/astro/src/vite-plugin-mdx/tag.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default async function tagExportsWithRenderer({
1818
return {
1919
visitor: {
2020
Program: {
21-
// Inject `import { __astro_tag_component__ } from 'astro/server/index.js'`
21+
// Inject `import { __astro_tag_component__ } from 'astro/runtime/server/index.js'`
2222
enter(path) {
2323
path.node.body.splice(
2424
0,
@@ -30,7 +30,7 @@ export default async function tagExportsWithRenderer({
3030
t.identifier('__astro_tag_component__')
3131
),
3232
],
33-
t.stringLiteral('astro/server/index.js')
33+
t.stringLiteral('astro/runtime/server/index.js')
3434
)
3535
);
3636
},

0 commit comments

Comments
 (0)