|
|
|
|
@ -42,24 +42,30 @@ export default [
|
|
|
|
|
index: "src/runtime/index.ts",
|
|
|
|
|
ssr: "src/runtime/ssr.ts",
|
|
|
|
|
},
|
|
|
|
|
output: ["esm", "cjs"].map((format) => {
|
|
|
|
|
const ext = format === "esm" ? "mjs" : "cjs";
|
|
|
|
|
return {
|
|
|
|
|
entryFileNames: (entry) => {
|
|
|
|
|
if (entry.isEntry) {
|
|
|
|
|
if (entry.name === "index") return `index.${ext}`;
|
|
|
|
|
else if (entry.name === "ssr") return `ssr.${ext}`;
|
|
|
|
|
output: ["esm", "cjs"].map(
|
|
|
|
|
/** @returns {import('rollup').OutputOptions} */
|
|
|
|
|
(format) => {
|
|
|
|
|
const ext = format === "esm" ? "mjs" : "cjs";
|
|
|
|
|
return {
|
|
|
|
|
entryFileNames: (entry) => {
|
|
|
|
|
if (entry.isEntry) {
|
|
|
|
|
if (entry.name === "index") return `index.${ext}`;
|
|
|
|
|
else if (entry.name === "ssr") return `ssr.${ext}`;
|
|
|
|
|
|
|
|
|
|
return `${entry.name}/index.${ext}`;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
manualChunks: (id) => {
|
|
|
|
|
if (id.endsWith("internal/index.ts")) return "internal";
|
|
|
|
|
},
|
|
|
|
|
format,
|
|
|
|
|
dir: ".",
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
|
return `${entry.name}/index.${ext}`;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
manualChunks: (id) => {
|
|
|
|
|
if (id.endsWith("internal/index.ts")) {
|
|
|
|
|
return "internal";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
format,
|
|
|
|
|
dir: ".",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
plugins: [
|
|
|
|
|
replace({
|
|
|
|
|
preventAssignment: true,
|
|
|
|
|
@ -67,19 +73,19 @@ export default [
|
|
|
|
|
__VERSION__: pkg.version,
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
,
|
|
|
|
|
ts_plugin,
|
|
|
|
|
{
|
|
|
|
|
writeBundle(_options, bundle) {
|
|
|
|
|
for (const [_, entry] of Object.entries(bundle)) {
|
|
|
|
|
const dir = entry.name;
|
|
|
|
|
if (!entry.isEntry || !runtime_entrypoints[dir]) continue;
|
|
|
|
|
|
|
|
|
|
if (dir === "internal") {
|
|
|
|
|
const mod = bundle[`internal/index.mjs`];
|
|
|
|
|
if (mod) {
|
|
|
|
|
fs.writeFileSync(
|
|
|
|
|
"src/compiler/compile/internal_exports.ts",
|
|
|
|
|
`// This file is automatically generated` +
|
|
|
|
|
`// This file is automatically generated\n` +
|
|
|
|
|
`export default new Set(${JSON.stringify(mod.exports)});`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -89,7 +95,7 @@ export default [
|
|
|
|
|
`${dir}/package.json`,
|
|
|
|
|
JSON.stringify(
|
|
|
|
|
{
|
|
|
|
|
main: "./index",
|
|
|
|
|
main: "./index.cjs",
|
|
|
|
|
module: "./index.mjs",
|
|
|
|
|
types: "./index.d.ts",
|
|
|
|
|
},
|
|
|
|
|
|