Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Commit 3f46a65

Browse files
committed
fix: cjs + esm + umd module
1 parent 45f28fc commit 3f46a65

File tree

4 files changed

+133
-1
lines changed

4 files changed

+133
-1
lines changed

package-lock.json

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
"name": "@govtechsg/oa-schemata",
33
"version": "0.0.0-development",
44
"description": "Repository for schemata created by open-attestation",
5+
"main": "dist/cjs/index.js",
6+
"module": "dist/esm/index.js",
7+
"browser": "dist/index.umd.js",
58
"types": "dist/types/index.d.ts",
69
"scripts": {
7-
"build": "npm run clean && npm run build:type",
10+
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:type",
11+
"build:cjs": "tsc --module commonjs --outDir dist/cjs --project ./tsconfig.prod.json",
12+
"build:esm": "tsc --module es2015 --outDir dist/esm --project ./tsconfig.prod.json",
813
"build:type": "tsc -d --emitDeclarationOnly --outDir dist/types",
14+
"build:umd": "rollup -c",
915
"clean": "rm -rf dist/",
1016
"dev": "cd app && npm run dev",
1117
"test": "jest",
@@ -21,6 +27,7 @@
2127
"@commitlint/config-conventional": "8.3.3",
2228
"@commitlint/prompt": "8.3.3",
2329
"@ls-age/commitlint-circle": "1.0.0",
30+
"@rollup/plugin-json": "^4.0.0",
2431
"@types/jest": "^24.0.23",
2532
"@types/lodash": "^4.14.162",
2633
"@typescript-eslint/eslint-plugin": "^2.8.0",
@@ -41,6 +48,8 @@
4148
"prettier": "^1.19.1",
4249
"prettier-plugin-svelte": "^1.4.1",
4350
"quicktype": "^15.0.258",
51+
"rollup": "^1.27.3",
52+
"rollup-plugin-commonjs": "^10.1.0",
4453
"semantic-release": "^17.2.1",
4554
"svelte": "^3.29.4",
4655
"ts-jest": "^24.1.0",

rollup.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import commonjs from "rollup-plugin-commonjs";
2+
import json from "@rollup/plugin-json";
3+
4+
export default {
5+
input: "./dist/esm/index.js", // umd will run from esm build to produce a single bundled file, any better idea ?
6+
output: {
7+
file: "./dist/index.umd.js",
8+
format: "umd",
9+
name: "openAttestation"
10+
},
11+
plugins: [commonjs(), json()]
12+
};

tsconfig.prod.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig",
3+
"exclude": [
4+
"**/*.test.ts"
5+
]
6+
}

0 commit comments

Comments
 (0)