@commercetools/nimbus-icons 2.11.0 → 3.1.0

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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/nimbus-icons",
3
- "version": "2.11.0",
3
+ "version": "3.1.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -31,16 +31,17 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@svgr/plugin-jsx": "^8.1.0",
34
- "@types/node": "^24.11.0",
35
- "@types/react": "^19.2.14",
34
+ "@types/node": "^24.13.0",
35
+ "@types/react": "^19.2.16",
36
36
  "react": "^19.0.0",
37
37
  "typescript": "~5.9.3"
38
38
  },
39
39
  "scripts": {
40
- "build": "pnpm run build:icons && pnpm run build:esm && pnpm run build:cjs",
40
+ "build": "pnpm run build:icons && pnpm run build:esm && pnpm run build:cjs && pnpm run build:postbuild",
41
41
  "build:icons": "pnpm svgr --filename-case kebab --typescript --jsx-runtime automatic --out-dir src/material-icons node_modules/@material-design-icons/svg/outlined",
42
42
  "build:esm": "tsc --project tsconfig.esm.json",
43
43
  "build:cjs": "tsc --project tsconfig.cjs.json",
44
- "dev": "pnpm run build:esm && pnpm run build:cjs"
44
+ "build:postbuild": "node scripts/postbuild.mjs",
45
+ "dev": "pnpm run build:esm && pnpm run build:cjs && pnpm run build:postbuild"
45
46
  }
46
47
  }
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Post-build fixups for the published nimbus-icons tarball.
5
+ *
6
+ * Two tasks:
7
+ *
8
+ * 1. Write marker package.json files into dist/esm and dist/cjs so Node
9
+ * knows how to interpret each directory's .js files. tsc emits .js
10
+ * without flipping extensions, and the root package has no "type" field
11
+ * — so without markers Node defaults to CJS by extension, breaking
12
+ * ESM consumers.
13
+ *
14
+ * 2. Walk dist/esm and rewrite bare relative imports (`from './foo'`) to
15
+ * include explicit `.js` extensions. Native Node ESM resolution requires
16
+ * extensions on relative imports; tsc doesn't add them. dist/cjs is left
17
+ * alone — CJS resolution supports extensionless imports natively. The
18
+ * shared rewriter lives at scripts/lib/rewrite-relative-imports.mjs.
19
+ */
20
+
21
+ import { writeFileSync } from "node:fs";
22
+ import { join } from "node:path";
23
+ import { fileURLToPath } from "node:url";
24
+ import { walkAndRewriteImports } from "../../../scripts/lib/rewrite-relative-imports.mjs";
25
+
26
+ const __dirname = fileURLToPath(new URL(".", import.meta.url));
27
+ const DIST = join(__dirname, "..", "dist");
28
+
29
+ // ---------------------------------------------------------------------------
30
+ // Step 1: dual-package markers
31
+
32
+ const MARKERS = [
33
+ ["esm", { type: "module" }],
34
+ ["cjs", { type: "commonjs" }],
35
+ ];
36
+
37
+ for (const [subdir, contents] of MARKERS) {
38
+ const path = join(DIST, subdir, "package.json");
39
+ writeFileSync(path, JSON.stringify(contents, null, 2) + "\n");
40
+ console.log(`[postbuild] wrote ${subdir}/package.json`);
41
+ }
42
+
43
+ // ---------------------------------------------------------------------------
44
+ // Step 2: rewrite bare relative imports under dist/esm
45
+
46
+ const esmDir = join(DIST, "esm");
47
+ const rewritten = walkAndRewriteImports(
48
+ esmDir,
49
+ (name) => name.endsWith(".js") || name.endsWith(".d.ts")
50
+ );
51
+ console.log(`[postbuild] rewrote imports in ${rewritten} esm file(s)`);