Skip to content

Commit 94140b5

Browse files
committed
chore: update build step to output umd version
1 parent eb6c5ef commit 94140b5

File tree

6 files changed

+453
-29
lines changed

6 files changed

+453
-29
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

package.json

+11-8
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@
66
"access": "public"
77
},
88
"packageManager": "[email protected]",
9-
"version": "1.0.0",
9+
"version": "1.7.1",
1010
"license": "MIT",
11-
"main": "dist/index.js",
12-
"module": "dist/index.mjs",
13-
"browser": "dist/umd/index.global.js",
11+
"main": "dist/index.min.js",
12+
"module": "dist/index.min.mjs",
13+
"browser": "dist/index.umd.min.js",
1414
"types": "dist/index.d.ts",
1515
"exports": {
1616
".": {
17-
"require": "./dist/index.js",
18-
"import": "./dist/index.mjs"
17+
"require": "./dist/index.min.js",
18+
"import": "./dist/index.min.mjs"
1919
},
20-
"./cdn": "./dist/umd/index.global.js"
20+
"./cdn": "./dist/index.umd.min.js"
2121
},
2222
"files": [
2323
"dist"
2424
],
2525
"scripts": {
26+
"postversion": "node ./scripts/postversion.mjs",
2627
"start": "tsup --watch",
2728
"build": "tsup",
2829
"test": "vitest run",
@@ -37,12 +38,14 @@
3738
"humps": "^2.0.1"
3839
},
3940
"devDependencies": {
40-
"cross-fetch": "^3.1.5",
4141
"@size-limit/preset-small-lib": "^7.0.8",
42+
"@swc/core": "^1.10.4",
4243
"@types/humps": "^2.0.1",
4344
"@typescript-eslint/eslint-plugin": "^5.42.0",
4445
"@typescript-eslint/parser": "^5.42.0",
4546
"@vitest/coverage-c8": "^0.24.4",
47+
"cross-fetch": "^3.1.5",
48+
"esbuild-plugin-umd-wrapper": "^3.0.0",
4649
"eslint": "^8.26.0",
4750
"eslint-config-prettier": "^8.5.0",
4851
"eslint-plugin-prettier": "^4.2.1",

pnpm-lock.yaml

+141-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/postversion.mjs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { fileURLToPath } from 'url';
2+
import fs from 'fs';
3+
import path from 'path';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
8+
const packageJson = fs.readFileSync(
9+
path.join(__dirname, '../package.json'),
10+
'utf8'
11+
);
12+
const version = JSON.parse(packageJson).version;
13+
14+
const dist = path.join(__dirname, '../dist');
15+
16+
// replace {{VERSION_TO_REPLACE}} in dist/* with the current version
17+
const files = fs.readdirSync(dist);
18+
files.forEach((file) => {
19+
const content = fs.readFileSync(path.join(dist, file), 'utf8');
20+
const newContent = content.replace('{{VERSION_TO_REPLACE}}', version);
21+
fs.writeFileSync(path.join(dist, file), newContent);
22+
});
23+
24+
// eslint-disable-next-line no-undef
25+
console.log('✅ Version replaced in dist/*');

0 commit comments

Comments
 (0)