Skip to content
This repository was archived by the owner on Aug 26, 2023. It is now read-only.

Commit 1f1b9fa

Browse files
committed
fix: replace microbundle with build script that handles hybrid packages better
1 parent d021986 commit 1f1b9fa

12 files changed

+197
-3617
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"parser": "@typescript-eslint/parser",
88
"parserOptions": {
99
"project": [
10-
"./tsconfig.json"
10+
"./tsconfig.esm.json"
1111
]
1212
},
1313
"plugins": [

build.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
#
3+
# SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
4+
#
5+
# SPDX-License-Identifier: AGPL-3.0-only
6+
#
7+
8+
set -e
9+
10+
echo "Clear dist directory.."
11+
rm -rf dist
12+
13+
echo "Compile to CJS.."
14+
tsc --project tsconfig.cjs.json
15+
16+
echo "Compile to ESM.."
17+
tsc --project tsconfig.esm.json
18+
19+
echo "Fix CJS package.json.."
20+
cat > dist/cjs/package.json <<!EOF
21+
{
22+
"type": "commonjs"
23+
}
24+
!EOF
25+
26+
echo "Fix ESM package.json.."
27+
cat > dist/esm/package.json <<!EOF
28+
{
29+
"type": "module"
30+
}
31+
!EOF
32+
33+
echo "Done!"

jest.config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"^.+\\.tsx?$" : [
1919
"ts-jest",
2020
{
21+
"tsconfig" : "tsconfig.esm.json",
2122
"useESM" : true
2223
}
2324
]

package.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
{
22
"name": "@hedgedoc/html-to-react",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Parse HTML into React components",
5-
"main": "dist/index.cjs",
6-
"module": "dist/index.mjs",
7-
"types": "dist/index.d.ts",
85
"source": "src/index.ts",
6+
"main": "dist/cjs/index.js",
7+
"types": "dist/cjs/index.d.ts",
8+
"module": "./dist/esm/index.js",
99
"exports": {
10-
"types": "./dist/index.d.ts",
11-
"import": "./dist/index.mjs",
12-
"require": "./dist/index.cjs"
10+
"import": {
11+
"types": "./dist/esm/index.d.ts",
12+
"default": "./dist/esm/index.js"
13+
},
14+
"require": {
15+
"types": "./dist/cjs/index.d.ts",
16+
"default": "./dist/cjs/index.js"
17+
}
1318
},
1419
"type": "module",
1520
"scripts": {
1621
"test": "jest",
17-
"build": "rm -rf dist && microbundle",
22+
"build": "./build.sh",
1823
"prepublish": "yarn lint && yarn build && yarn test",
1924
"lint": "eslint src --ext .ts",
2025
"lint:fix": "eslint --fix --ext .ts src"
@@ -51,7 +56,6 @@
5156
"eslint-plugin-jest": "27.2.3",
5257
"eslint-plugin-prettier": "5.0.0",
5358
"jest": "29.6.2",
54-
"microbundle": "0.15.1",
5559
"prettier": "3.0.0",
5660
"react": "18.2.0",
5761
"react-dom": "18.2.0",
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
{
22
"compilerOptions": {
3-
"target": "esnext",
43
"removeComments": true,
54
"preserveConstEnums": true,
65
"lib": [
7-
"es2020",
6+
"es2022",
87
"dom"
98
],
109
"declaration": true,
1110
"strict": true,
1211
"allowSyntheticDefaultImports": true,
1312
"forceConsistentCasingInFileNames": true,
14-
"module": "esnext",
15-
"moduleResolution": "NodeNext",
13+
"moduleResolution": "node",
1614
"esModuleInterop": true,
17-
"outDir": "dist/",
18-
"rootDir": "./src",
1915
"allowJs": true,
2016
"sourceMap": true,
2117
"jsx": "react"
2218
},
23-
"include": ["src"]
19+
"include": ["src"],
20+
"exclude": ["dist"]
2421
}

tsconfig.base.json.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2023 Tilman Vatteroth
2+
3+
SPDX-License-Identifier: CC0-1.0

tsconfig.cjs.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends" : "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "CommonJS",
5+
"target": "ES2015",
6+
"outDir": "dist/cjs",
7+
"declarationDir": "dist/cjs"
8+
}
9+
}

tsconfig.cjs.json.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2023 Tilman Vatteroth
2+
3+
SPDX-License-Identifier: CC0-1.0

tsconfig.esm.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends" : "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "ESNext",
5+
"target" : "esnext",
6+
"outDir": "dist/esm",
7+
"declarationDir": "dist/esm"
8+
}
9+
}

tsconfig.esm.json.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2023 Tilman Vatteroth
2+
3+
SPDX-License-Identifier: CC0-1.0

tsconfig.json.license

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)