Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions libs/@hashintel/petrinaut-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,46 @@
"type": "module",
"sideEffects": false,
"main": "./dist/index.js",
"types": "./dist/index.d.d.ts",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.d.ts",
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./ai": {
"types": "./dist/ai.d.d.ts",
"types": "./dist/ai.d.ts",
"import": "./dist/ai.js"
},
"./compiled-model": {
"types": "./dist/compiled-model.d.d.ts",
"types": "./dist/compiled-model.d.ts",
"import": "./dist/compiled-model.js"
},
"./examples": {
"types": "./dist/examples/index.d.d.ts",
"types": "./dist/examples/index.d.ts",
"import": "./dist/examples/index.js"
},
"./hir": {
"types": "./dist/hir.d.d.ts",
"types": "./dist/hir.d.ts",
"import": "./dist/hir.js"
},
"./hir-runtime": {
"types": "./dist/hir-runtime.d.d.ts",
"types": "./dist/hir-runtime.d.ts",
"import": "./dist/hir-runtime.js"
},
"./optimization": {
"types": "./dist/optimization.d.d.ts",
"types": "./dist/optimization.d.ts",
"import": "./dist/optimization.js"
},
"./workers/lsp": {
"types": "./dist/workers/lsp.d.d.ts",
"types": "./dist/workers/lsp.d.ts",
"import": "./dist/workers/lsp.js"
},
"./workers/monte-carlo": {
"types": "./dist/workers/monte-carlo.d.d.ts",
"types": "./dist/workers/monte-carlo.d.ts",
"import": "./dist/workers/monte-carlo.js"
},
"./workers/simulation": {
"types": "./dist/workers/simulation.d.d.ts",
"types": "./dist/workers/simulation.d.ts",
"import": "./dist/workers/simulation.js"
},
"./package.json": "./package.json"
Expand Down Expand Up @@ -90,10 +90,10 @@
"@typescript/native-preview": "7.0.0-dev.20260511.1",
"oxlint": "1.63.0",
"oxlint-tsgolint": "0.22.1",
"rolldown": "1.1.2",
"rolldown-plugin-dts": "0.25.0",
"rolldown": "1.2.6",
"rolldown-plugin-dts": "0.28.3",
"typescript": "5.9.3",
"vite": "8.1.0",
"vite": "8.2.2",
"vitest": "4.1.10"
},
"peerDependencies": {
Expand Down
16 changes: 8 additions & 8 deletions libs/@hashintel/petrinaut-core/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export default defineConfig(({ command }) => ({
},
rolldownOptions: {
external: [
// Peer (optional): only the ./hir compiler entry needs it.
"typescript",
"elkjs",
"immer",
"js-yaml",
Expand All @@ -51,6 +49,12 @@ export default defineConfig(({ command }) => ({
emptyOutDir: true,
},

// rolldown-plugin-dts emits declaration modules that Vite must not
// transform as JavaScript. Setting this replaces Vite's default exclusions.
oxc: {
exclude: [/\.js$/, /\.d\.[cm]?ts$/],
},

define: {
"process.versions": JSON.stringify({ pnp: undefined }),
},
Expand All @@ -71,15 +75,11 @@ export default defineConfig(({ command }) => ({

plugins: [
esmExternalRequirePlugin({
// Peer (optional): only the ./hir compiler entry needs it.
external: ["typescript"],
}),

command === "build" &&
dts({ tsgo: true }).map((plugin) =>
plugin.name.endsWith("fake-js")
? { ...plugin, enforce: "pre" }
: plugin,
),
command === "build" && dts({ generator: "tsgo" }),
],

experimental: {
Expand Down
16 changes: 8 additions & 8 deletions libs/@hashintel/petrinaut/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
"*.css"
],
"main": "dist/main.js",
"types": "dist/main.d.d.ts",
"types": "dist/main.d.ts",
"exports": {
".": {
"types": "./dist/main.d.d.ts",
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
},
"./react": {
"types": "./dist/react.d.d.ts",
"types": "./dist/react.d.ts",
"default": "./dist/react.js"
},
"./ui": {
"types": "./dist/ui.d.d.ts",
"types": "./dist/ui.d.ts",
"default": "./dist/ui.js"
},
"./styles.css": "./dist/main.css",
"./dist/main.css": "./dist/main.css",
"./panda-preset": {
"types": "./dist/panda-preset.d.d.ts",
"types": "./dist/panda-preset.d.ts",
"default": "./dist/panda-preset.js"
},
"./panda.buildinfo.json": "./dist/panda.buildinfo.json",
Expand Down Expand Up @@ -100,10 +100,10 @@
"oxlint-tsgolint": "0.22.1",
"react": "19.2.6",
"react-dom": "19.2.6",
"rolldown": "1.1.2",
"rolldown-plugin-dts": "0.25.0",
"rolldown": "1.2.6",
"rolldown-plugin-dts": "0.28.3",
"storybook": "10.4.6",
"vite": "8.1.0",
"vite": "8.2.2",
"vitest": "4.1.10"
},
"peerDependencies": {
Expand Down
71 changes: 40 additions & 31 deletions libs/@hashintel/petrinaut/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,37 @@ import react from "@vitejs/plugin-react";
import { dts } from "rolldown-plugin-dts";
import { defineConfig, esmExternalRequirePlugin } from "vite";

const declarationFilePattern = /\.d\.[cm]?ts$/;

const externalDependencies = [
"@hashintel/ds-components",
"@hashintel/ds-helpers",
/^@hashintel\/petrinaut-core(\/.*)?$/,
"react",
"react-dom",
"@xyflow/react",
"@babel/standalone",
// Pure-CJS dep pulled in transitively by @tanstack/react-form β†’
// @tanstack/react-store. Rolldown can't safely transform its
// `require("react")` when react is external, so it falls back to a
// runtime require helper that throws in the browser. Externalising it
// pushes CJS→ESM interop to the consumer's bundler.
/^use-sync-external-store(\/.*)?$/,
] as const;

const isExternalDependency = (id: string) =>
externalDependencies.some((dependency) =>
typeof dependency === "string" ? id === dependency : dependency.test(id),
);

/**
* Library build config
*/
export default defineConfig(({ command }) => ({
build: {
lib: {
// Three entry points: the legacy `main` (back-compat), plus the
// React/UI split per RFC 0001. Each emits its own JS + dts bundle.
// Keep the legacy `main` entry for back-compat alongside the React/UI
// split from RFC 0001 and the preset consumed by host Panda pipelines.
entry: {
main: "src/main.ts",
react: "src/react/index.ts",
Expand All @@ -26,27 +49,13 @@ export default defineConfig(({ command }) => ({
formats: ["es"],
},
rolldownOptions: {
external: [
"@hashintel/ds-components",
"@hashintel/ds-helpers",
/^@hashintel\/petrinaut-core(\/.*)?$/,
"react",
"react-dom",
"@xyflow/react",
"@babel/standalone",
// Pure-CJS dep pulled in transitively by @tanstack/react-form β†’
// @tanstack/react-store. Rolldown can't safely transform its
// `require("react")` when react is external, so it falls back to a
// runtime require helper that throws in the browser. Externalising it
// pushes CJS→ESM interop to the consumer's bundler.
/^use-sync-external-store(\/.*)?$/,
],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
},
},
external: (id, importer) =>
isExternalDependency(id) ||
// Keep the AI SDK's transitive declaration graph out of Petrinaut's
// bundled types without externalizing its runtime JavaScript.
(id === "ai" &&
importer !== undefined &&
declarationFilePattern.test(importer)),
},
sourcemap: true,
minify: true,
Expand All @@ -55,6 +64,12 @@ export default defineConfig(({ command }) => ({
cssMinify: "esbuild",
},

// rolldown-plugin-dts emits declaration modules that Vite must not
// transform as JavaScript. Setting this replaces Vite's default exclusions.
oxc: {
exclude: [/\.js$/, declarationFilePattern],
},

plugins: [
esmExternalRequirePlugin({
external: [
Expand All @@ -72,7 +87,7 @@ export default defineConfig(({ command }) => ({
exclude: [
/[\\/]node_modules[\\/]/,
/[\\/]libs[\\/]@hashintel[\\/][^\\/]+[\\/]dist[\\/]/,
/\.d\.ts$/,
declarationFilePattern,
/^0rolldown\/runtime\.js$/,
],
compiler: {
Expand All @@ -82,13 +97,7 @@ export default defineConfig(({ command }) => ({
},
}),

command === "build" &&
dts({ tsgo: true }).map((plugin) =>
// Ensure runs before Vite's native TypeScript transform
plugin.name.endsWith("fake-js")
? { ...plugin, enforce: "pre" }
: plugin,
),
command === "build" && dts({ generator: "tsgo" }),
],

experimental: {
Expand Down
5 changes: 3 additions & 2 deletions libs/@hashintel/refractive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
"oxlint-tsgolint": "0.22.1",
"react": "19.2.6",
"react-dom": "19.2.6",
"rolldown-plugin-dts": "0.25.0",
"rolldown": "1.2.6",
"rolldown-plugin-dts": "0.28.3",
"storybook": "10.4.6",
"vite": "8.1.0"
"vite": "8.2.2"
},
"peerDependencies": {
"react": "^19.0.0",
Expand Down
28 changes: 12 additions & 16 deletions libs/@hashintel/refractive/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,28 @@ import react from "@vitejs/plugin-react";
import { dts } from "rolldown-plugin-dts";
import { defineConfig } from "vite";

const declarationFilePattern = /\.d\.[cm]?ts$/;

export default defineConfig(({ command }) => ({
plugins: [
react({
// The native compiler also transforms TypeScript syntax, so exclude the
// declarations generated by rolldown-plugin-dts from that transform.
exclude: [/[\\/]node_modules[\\/]/, /\.d\.ts$/],
exclude: [/[\\/]node_modules[\\/]/, declarationFilePattern],
compiler: {
target: "19",
compilationMode: "infer",
panicThreshold: "critical_errors",
},
}),

command === "build" &&
dts({ tsgo: true }).map((plugin) =>
// Ensure runs before Vite's native TypeScript transform
plugin.name.endsWith("fake-js")
? { ...plugin, enforce: "pre" }
: plugin,
),
command === "build" && dts({ generator: "tsgo" }),
],

build: {
lib: {
entry: "src/main.ts",
fileName: "index",
entry: { index: "src/main.ts" },
fileName: (_format, entryName) => `${entryName}.js`,
formats: ["es"],
},
rolldownOptions: {
Expand All @@ -38,15 +34,15 @@ export default defineConfig(({ command }) => ({
"react/jsx-dev-runtime",
"react/compiler-runtime",
],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
},
},
},
sourcemap: true,
emptyOutDir: true,
minify: true,
},

// rolldown-plugin-dts emits declaration modules that Vite must not
// transform as JavaScript. Setting this replaces Vite's default exclusions.
oxc: {
exclude: [/\.js$/, declarationFilePattern],
},
}));
Loading
Loading