v1.0.200
🐛 Fix: chip view crashed in prod with createRequire is not a function
After the v1.0.198 / v1.0.199 install path was fixed, opening the 代码块 / Code Map chip view in a prod build threw:
Uncaught (in promise) TypeError: createRequire is not a function
web-tree-sitter's ESM bundle has a runtime Node-detection branch that calls createRequire only when it thinks it's running in Node:
var ENVIRONMENT_IS_NODE = typeof process == "object" && process.versions?.node && process.type != "renderer";
if (ENVIRONMENT_IS_NODE) {
const { createRequire } = await import("module");
var require = createRequire(import.meta.url);
}Next.js's webpack browser polyfill exposes process.versions.node, so the gate evaluated truthy in the browser and the dynamic import("module") resolved to our empty stub — createRequire was undefined.
This release adds a webpack DefinePlugin rule for the browser bundle that folds process.versions to ({}) and process.type to "renderer" at compile time. The if-condition then collapses to falsy && void 0 && false ≡ undefined, so the Node branch never runs in the browser. Server bundle is untouched.
Same v1.0.198 / v1.0.199 changes ship in this release; just the build now actually loads in production.
npm install -g @surething/cockpit@latest