@astrojs/cloudflare 13.0.0-alpha.1 → 13.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -91,7 +91,7 @@ function serverStart({
|
|
|
91
91
|
host,
|
|
92
92
|
base
|
|
93
93
|
}) {
|
|
94
|
-
const version = "13.0.0-alpha.
|
|
94
|
+
const version = "13.0.0-alpha.2";
|
|
95
95
|
const localPrefix = `${colors.dim("\u2503")} Local `;
|
|
96
96
|
const networkPrefix = `${colors.dim("\u2503")} Network `;
|
|
97
97
|
const emptyPrefix = " ".repeat(11);
|
package/dist/index.js
CHANGED
|
@@ -91,11 +91,13 @@ function createIntegration(args) {
|
|
|
91
91
|
{
|
|
92
92
|
name: "@astrojs/cloudflare:cf-imports",
|
|
93
93
|
enforce: "pre",
|
|
94
|
-
resolveId
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
resolveId: {
|
|
95
|
+
filter: {
|
|
96
|
+
id: /^cloudflare:/
|
|
97
|
+
},
|
|
98
|
+
handler(id) {
|
|
99
|
+
return { id, external: true };
|
|
97
100
|
}
|
|
98
|
-
return null;
|
|
99
101
|
}
|
|
100
102
|
},
|
|
101
103
|
{
|
|
@@ -119,15 +121,25 @@ function createIntegration(args) {
|
|
|
119
121
|
"astro > @oslojs/encoding",
|
|
120
122
|
"astro > es-module-lexer",
|
|
121
123
|
"astro > unstorage",
|
|
122
|
-
"astro > neotraverse/modern"
|
|
124
|
+
"astro > neotraverse/modern",
|
|
125
|
+
"astro/app",
|
|
126
|
+
"astro/compiler-runtime"
|
|
123
127
|
],
|
|
124
128
|
exclude: [
|
|
125
129
|
"unstorage/drivers/cloudflare-kv-binding",
|
|
126
|
-
"astro
|
|
127
|
-
"virtual:astro
|
|
130
|
+
"astro:*",
|
|
131
|
+
"virtual:astro:*",
|
|
132
|
+
"virtual:astro-cloudflare:*"
|
|
128
133
|
]
|
|
129
134
|
}
|
|
130
135
|
};
|
|
136
|
+
} else if (environmentName === "client") {
|
|
137
|
+
return {
|
|
138
|
+
optimizeDeps: {
|
|
139
|
+
include: ["astro/runtime/client/dev-toolbar/entrypoint.js"],
|
|
140
|
+
exclude: ["astro:*"]
|
|
141
|
+
}
|
|
142
|
+
};
|
|
131
143
|
}
|
|
132
144
|
}
|
|
133
145
|
},
|
|
@@ -28,42 +28,45 @@ function cloudflareModuleLoader(enabled) {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
load: {
|
|
32
|
+
filter: {
|
|
33
|
+
// Escape the dot in the regex
|
|
34
|
+
id: new RegExp(`.(${extensions.map((ext) => ext.slice(1)).join("|")})$`)
|
|
35
|
+
},
|
|
36
|
+
async handler(id, _) {
|
|
37
|
+
const maybeExtension = extensions.find((x) => id.endsWith(x));
|
|
38
|
+
const moduleType = adaptersByExtension[maybeExtension];
|
|
39
|
+
if (!enabled) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Cloudflare module loading is experimental. The ${maybeExtension} module cannot be loaded unless you add \`cloudflareModules: true\` to your astro config.`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const moduleLoader = renderers[moduleType];
|
|
45
|
+
const filePath = id.replace(/\?\w+$/, "");
|
|
46
|
+
const extension = maybeExtension.replace(/\?\w+$/, "");
|
|
47
|
+
const data = await fs.readFile(filePath);
|
|
48
|
+
const base64 = data.toString("base64");
|
|
49
|
+
const inlineModule = moduleLoader(data);
|
|
50
|
+
if (isDev) {
|
|
51
|
+
return inlineModule;
|
|
52
|
+
}
|
|
53
|
+
const hash = hashString(base64);
|
|
54
|
+
const assetName = `${path.basename(filePath).split(".")[0]}.${hash}${extension}`;
|
|
55
|
+
this.emitFile({
|
|
56
|
+
type: "asset",
|
|
57
|
+
// emit the data explicitly as an asset with `fileName` rather than `name` so that
|
|
58
|
+
// vite doesn't give it a random hash-id in its name--We need to be able to easily rewrite from
|
|
59
|
+
// the loader and the actual asset later in the build for the worker
|
|
60
|
+
fileName: assetName,
|
|
61
|
+
source: data
|
|
62
|
+
});
|
|
63
|
+
const chunkId = this.emitFile({
|
|
64
|
+
type: "prebuilt-chunk",
|
|
65
|
+
fileName: assetName,
|
|
66
|
+
code: inlineModule
|
|
67
|
+
});
|
|
68
|
+
return `import module from "${MAGIC_STRING}${chunkId}${extension}";export default module;`;
|
|
50
69
|
}
|
|
51
|
-
const hash = hashString(base64);
|
|
52
|
-
const assetName = `${path.basename(filePath).split(".")[0]}.${hash}${extension}`;
|
|
53
|
-
this.emitFile({
|
|
54
|
-
type: "asset",
|
|
55
|
-
// emit the data explicitly as an asset with `fileName` rather than `name` so that
|
|
56
|
-
// vite doesn't give it a random hash-id in its name--We need to be able to easily rewrite from
|
|
57
|
-
// the loader and the actual asset later in the build for the worker
|
|
58
|
-
fileName: assetName,
|
|
59
|
-
source: data
|
|
60
|
-
});
|
|
61
|
-
const chunkId = this.emitFile({
|
|
62
|
-
type: "prebuilt-chunk",
|
|
63
|
-
fileName: assetName,
|
|
64
|
-
code: inlineModule
|
|
65
|
-
});
|
|
66
|
-
return `import module from "${MAGIC_STRING}${chunkId}${extension}";export default module;`;
|
|
67
70
|
},
|
|
68
71
|
// output original wasm file relative to the chunk now that chunking has been achieved
|
|
69
72
|
renderChunk(code, chunk, _) {
|
|
@@ -3,13 +3,19 @@ const RESOLVED_VIRTUAL_CONFIG_ID = "\0" + VIRTUAL_CONFIG_ID;
|
|
|
3
3
|
function createConfigPlugin(config) {
|
|
4
4
|
return {
|
|
5
5
|
name: "vite:astro-cloudflare-config",
|
|
6
|
-
resolveId
|
|
7
|
-
|
|
6
|
+
resolveId: {
|
|
7
|
+
filter: {
|
|
8
|
+
id: new RegExp(`^${VIRTUAL_CONFIG_ID}$`)
|
|
9
|
+
},
|
|
10
|
+
handler() {
|
|
8
11
|
return RESOLVED_VIRTUAL_CONFIG_ID;
|
|
9
12
|
}
|
|
10
13
|
},
|
|
11
|
-
load
|
|
12
|
-
|
|
14
|
+
load: {
|
|
15
|
+
filter: {
|
|
16
|
+
id: new RegExp(`^${RESOLVED_VIRTUAL_CONFIG_ID}$`)
|
|
17
|
+
},
|
|
18
|
+
handler() {
|
|
13
19
|
return `export const sessionKVBindingName = ${JSON.stringify(config.sessionKVBindingName)};`;
|
|
14
20
|
}
|
|
15
21
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/cloudflare",
|
|
3
3
|
"description": "Deploy your site to Cloudflare Workers/Pages",
|
|
4
|
-
"version": "13.0.0-alpha.
|
|
4
|
+
"version": "13.0.0-alpha.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"cheerio": "1.1.2",
|
|
52
52
|
"devalue": "^5.5.0",
|
|
53
53
|
"rollup": "^4.53.3",
|
|
54
|
-
"astro": "6.0.0-alpha.
|
|
54
|
+
"astro": "6.0.0-alpha.2",
|
|
55
55
|
"astro-scripts": "0.0.14"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|