nowebcli 0.2.11 → 0.2.12

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nowebcli",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "Create, preview and publish community templates for Noweb",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,5 +1,6 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import { existsSync } from "node:fs";
3
+ import { createRequire } from "node:module";
3
4
  import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
4
5
  import { tmpdir } from "node:os";
5
6
  import path from "node:path";
@@ -17,6 +18,8 @@ const modulesPath = existsSync(path.join(packageModulesPath, ".bin", "esbuild"))
17
18
  ? packageModulesPath
18
19
  : path.join(process.cwd(), "node_modules");
19
20
 
21
+ const require = createRequire(import.meta.url);
22
+
20
23
  const TEMPLATE_COMPILE_TIMEOUT_MS = 10_000;
21
24
  const TEMPLATE_COMPILE_MAX_BUFFER = 8 * 1024 * 1024;
22
25
  const TEMPLATE_RUNTIME_IMPORT = "noweb";
@@ -165,6 +168,10 @@ function customizationDefaults(
165
168
 
166
169
  function runtimeAliases() {
167
170
  return [
171
+ // npx and project dependencies must share the renderer's React instance.
172
+ ...["react", "react-dom"].map((name) =>
173
+ `--alias:${name}=${path.dirname(require.resolve(`${name}/package.json`, { paths: [modulesPath] }))}`,
174
+ ),
168
175
  ...TEMPLATE_RUNTIME_IMPORTS.map(
169
176
  (moduleName) => `--alias:${moduleName}=${templateRuntimePath()}`,
170
177
  ),