@arkyn/templates 3.0.1-beta.147 → 3.0.1-beta.149

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.
Files changed (2) hide show
  1. package/generate-exports.ts +57 -0
  2. package/package.json +25 -2
@@ -0,0 +1,57 @@
1
+ import { resolve } from "node:path";
2
+ import Bun from "bun";
3
+
4
+ interface ExportEntry {
5
+ import: string;
6
+ types?: string;
7
+ }
8
+
9
+ interface PackageJson {
10
+ exports?: Record<string, ExportEntry>;
11
+ [key: string]: unknown;
12
+ }
13
+
14
+ const root = process.cwd();
15
+
16
+ const indexContent = await Bun.file(resolve(root, "src/index.ts")).text();
17
+
18
+ const packageJson = (await Bun.file(
19
+ resolve(root, "package.json"),
20
+ ).json()) as PackageJson;
21
+
22
+ const exportsMap: Record<string, ExportEntry> = {};
23
+
24
+ const regex =
25
+ /export\s+(?:\*|\{[\s\S]*?\}|type\s+\{[\s\S]*?\})\s+from\s+["'](.+)["']/g;
26
+
27
+ for (const match of indexContent.matchAll(regex)) {
28
+ let importPath = match[1];
29
+
30
+ if (!importPath.startsWith(".")) continue;
31
+
32
+ importPath = importPath.replace(/^\.\//, "");
33
+
34
+ const exportName = importPath.split("/").pop()!;
35
+
36
+ exportsMap[`./${exportName}`] = {
37
+ import: `./dist/${importPath}/index.js`,
38
+ types: `./dist/${importPath}/index.d.ts`,
39
+ };
40
+ }
41
+
42
+ packageJson.exports = {
43
+ ".": {
44
+ import: "./dist/bundle.js",
45
+ types: "./dist/index.d.ts",
46
+ },
47
+ ...Object.fromEntries(
48
+ Object.entries(exportsMap).sort(([a], [b]) => a.localeCompare(b)),
49
+ ),
50
+ };
51
+
52
+ await Bun.write(
53
+ resolve(root, "package.json"),
54
+ JSON.stringify(packageJson, null, 2) + "\n",
55
+ );
56
+
57
+ console.log(`Added ${Object.keys(exportsMap).length + 2} exports.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/templates",
3
- "version": "3.0.1-beta.147",
3
+ "version": "3.0.1-beta.149",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./dist/bundle.js",
6
6
  "type": "module",
@@ -24,8 +24,31 @@
24
24
  "git+url": "https://github.com/Lucas-Eduardo-Goncalves/arkyn.git",
25
25
  "directory": "packages/templates"
26
26
  },
27
+ "sideEffects": false,
28
+ "exports": {
29
+ ".": {
30
+ "import": "./dist/bundle.js",
31
+ "types": "./dist/index.d.ts"
32
+ },
33
+ "./brazilianStates": {
34
+ "import": "./dist/brazilianStates/index.js",
35
+ "types": "./dist/brazilianStates/index.d.ts"
36
+ },
37
+ "./countries": {
38
+ "import": "./dist/countries/index.js",
39
+ "types": "./dist/countries/index.d.ts"
40
+ },
41
+ "./countryCurrencies": {
42
+ "import": "./dist/countryCurrencies/index.js",
43
+ "types": "./dist/countryCurrencies/index.d.ts"
44
+ },
45
+ "./maximumFractionDigits": {
46
+ "import": "./dist/maximumFractionDigits/index.js",
47
+ "types": "./dist/maximumFractionDigits/index.d.ts"
48
+ }
49
+ },
27
50
  "scripts": {
28
- "build": "bunx vite build && tsc",
51
+ "build": "bunx vite build && tsc && bun ./generate-exports.ts",
29
52
  "typecheck": "bunx tsc --project tsconfig.json --noEmit"
30
53
  },
31
54
  "dependencies": {},