Skip to content

Commit c7063c9

Browse files
feat: esbuild
1 parent fce3587 commit c7063c9

File tree

14 files changed

+164
-48
lines changed

14 files changed

+164
-48
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ dist
1515
.env.test.local
1616
.env.production.local
1717
.cache
18+
tsconfig.tsbuildinfo
1819

1920
npm-debug.log*
2021
yarn-debug.log*
2122
yarn-error.log*
22-
.vscode/settings.json
23+
.vscode/settings.json
2324

2425
.next/
2526
.vercel/

examples/full/lib/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// TODO: change these to your own values
22
// NOTE: rootNotionSpaceId is optional; set it to undefined if you don't want to
33
// use it.
4-
export const rootNotionPageId = '067dd719a912471ea9a3ac10710e7fdf'
4+
// export const rootNotionPageId = '067dd719a912471ea9a3ac10710e7fdf'
5+
export const rootNotionPageId = '2fea615a97a7401c81be486e4eec2e94'
56
export const rootNotionSpaceId = 'fde5ac74-eea3-4527-8f00-4482710e1af3'
67

78
// NOTE: having this enabled can be pretty expensive as it re-generates preview

examples/full/pages/[pageId].tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export const getStaticProps = async (context) => {
2727
}
2828

2929
export async function getStaticPaths() {
30-
if (isDev) {
30+
const no = true
31+
if (isDev || no) {
3132
return {
3233
paths: [],
3334
fallback: true

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
"examples/*"
1515
],
1616
"scripts": {
17-
"build": "lerna run build --no-private",
18-
"watch": "tsc --watch",
17+
"build": "run-s build:tsc build:bundle",
18+
"build:tsc": "tsc --build",
19+
"build:bundle": "lerna run bundle --no-private",
20+
"watch": "tsc --build tsconfig.json --watch",
1921
"dev": "run-s watch",
2022
"prebuild": "run-s clean",
2123
"prewatch": "run-s clean",
@@ -39,6 +41,7 @@
3941
"ava": "^4.1.0",
4042
"del-cli": "^4.0.1",
4143
"esbuild": "^0.14.27",
44+
"esbuild-node-externals": "^1.4.1",
4245
"eslint": "^8.11.0",
4346
"eslint-config-prettier": "^8.5.0",
4447
"eslint-plugin-react": "^7.29.4",
@@ -50,6 +53,7 @@
5053
"npm-run-all": "^4.1.5",
5154
"prettier": "^2.6.0",
5255
"ts-node": "^10.7.0",
56+
"tsup": "^5.12.1",
5357
"typescript": "^4.6.2"
5458
},
5559
"lint-staged": {

packages/notion-client/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
"repository": "NotionX/react-notion-x",
77
"author": "Travis Fischer <[email protected]>",
88
"license": "MIT",
9-
"source": "./src/index.ts",
109
"module": "./build/index.js",
1110
"typings": "./build/index.d.ts",
1211
"sideEffects": false,
1312
"engines": {
1413
"node": ">=12"
1514
},
1615
"scripts": {
17-
"build": "microbundle -f esm --no-compress -i src/index.ts -o build/index.js --no-pkg-main",
16+
"bundle": "esbuild src/index.ts --bundle --outdir=build --format=esm --sourcemap --target=node12 --platform=node --external:./node_modules/*",
1817
"test": "ava 'build/**/*.test.js'"
1918
},
2019
"dependencies": {

packages/notion-client/src/notion-api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export class NotionAPI {
158158
// It's possible for public pages to link to private collections, in which case
159159
// Notion returns a 400 error
160160
console.warn('NotionAPI collectionQuery error', err.message)
161+
console.error(err)
161162
}
162163
},
163164
{
@@ -336,6 +337,7 @@ export class NotionAPI {
336337
property,
337338
value: { value, type }
338339
} = group
340+
339341
for (const iterator of iterators) {
340342
const iteratorProps =
341343
iterator === 'results'

packages/notion-client/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"compilerOptions": {
44
"composite": true,
55
"rootDir": "src",
6-
"outDir": "build"
6+
"outDir": "build",
7+
"tsBuildInfoFile": "build/.tsbuildinfo",
8+
"emitDeclarationOnly": true
79
},
810
"include": ["src"],
911
"references": [{ "path": "../notion-types" }, { "path": "../notion-utils" }]

packages/notion-types/package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@
66
"repository": "NotionX/react-notion-x",
77
"author": "Travis Fischer <[email protected]>",
88
"license": "MIT",
9-
"source": "./src/index.ts",
10-
"module": "./build/index.js",
119
"typings": "./build/index.d.ts",
1210
"sideEffects": false,
1311
"engines": {
1412
"node": ">=12"
15-
},
16-
"scripts": {
17-
"build": "microbundle -f esm --no-compress -i src/index.ts -o build/index.js --no-pkg-main"
1813
}
1914
}

packages/notion-types/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"compilerOptions": {
44
"composite": true,
55
"rootDir": "src",
6-
"outDir": "build"
6+
"outDir": "build",
7+
"tsBuildInfoFile": "build/.tsbuildinfo",
8+
"emitDeclarationOnly": true
79
},
810
"include": ["src"]
911
}

packages/notion-utils/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"repository": "NotionX/react-notion-x",
77
"author": "Travis Fischer <[email protected]>",
88
"license": "MIT",
9-
"source": "./src/index.ts",
109
"module": "./build/index.js",
1110
"typings": "./build/index.d.ts",
1211
"exports": {
@@ -20,7 +19,7 @@
2019
"node": ">=12"
2120
},
2221
"scripts": {
23-
"build": "microbundle -f esm --no-compress -i src/index.ts -o build/index.js --no-pkg-main",
22+
"bundle": "esbuild src/index.ts --bundle --outdir=build --format=esm --sourcemap --external:./node_modules/*",
2423
"test": "ava"
2524
},
2625
"dependencies": {

packages/notion-utils/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"composite": true,
55
"rootDir": "src",
66
"outDir": "build",
7-
"paths": {
8-
"notion-types": ["../notion-types"]
9-
}
7+
"tsBuildInfoFile": "build/.tsbuildinfo",
8+
"emitDeclarationOnly": true
109
},
1110
"include": ["src"],
1211
"references": [{ "path": "../notion-types" }]

packages/react-notion-x/package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@
66
"repository": "NotionX/react-notion-x",
77
"author": "Travis Fischer <[email protected]>",
88
"license": "MIT",
9-
"source": "./src/index.tsx",
109
"module": "./build/index.js",
1110
"typings": "./build/index.d.ts",
1211
"sideEffects": false,
1312
"engines": {
1413
"node": ">=12"
1514
},
1615
"scripts": {
17-
"build": "run-s build:*",
18-
"build:index": "microbundle -f esm --no-compress -i src/index.tsx -o build/index.js --no-pkg-main",
19-
"build:code": "microbundle -f esm --no-compress -i src/third-party/code.tsx -o build/third-party/code.js --no-pkg-main",
20-
"build:collection": "microbundle -f esm --no-compress -i src/third-party/collection.tsx -o build/third-party/collection.js --no-pkg-main",
21-
"build:equation": "microbundle -f esm --no-compress -i src/third-party/equation.tsx -o build/third-party/equation.js --no-pkg-main",
22-
"build:modal": "microbundle -f esm --no-compress -i src/third-party/modal.tsx -o build/third-party/modal.js --no-pkg-main",
23-
"build:pdf": "microbundle -f esm --no-compress -i src/third-party/pdf.tsx -o build/third-party/pdf.js --no-pkg-main"
16+
"bundle": "run-s bundle:*",
17+
"bundle:index": "esbuild src/index.tsx --bundle --outdir=build --format=esm --sourcemap --target=es2015 --external:./node_modules/*",
18+
"bundle:code": "esbuild src/third-party/code.tsx --bundle --outdir=build/third-party --format=esm --sourcemap --target=es2015 --external:./node_modules/*",
19+
"bundle:collection": "esbuild src/third-party/collection.tsx --bundle --outdir=build/third-party --format=esm --sourcemap --target=es2015 --external:./node_modules/*",
20+
"bundle:equation": "esbuild src/third-party/equation.tsx --bundle --outdir=build/third-party --format=esm --sourcemap --target=es2015 --external:./node_modules/*",
21+
"bundle:modal": "esbuild src/third-party/modal.tsx --bundle --outdir=build/third-party --format=esm --sourcemap --target=es2015 --external:./node_modules/*",
22+
"bundle:pdf": "esbuild src/third-party/pdf.tsx --bundle --outdir=build/third-party --format=esm --sourcemap --target=es2015 --external:./node_modules/*"
2423
},
2524
"dependencies": {
2625
"@matejmazur/react-katex": "^3.1.3",

packages/react-notion-x/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"composite": true,
55
"rootDir": "src",
66
"outDir": "build",
7+
"tsBuildInfoFile": "build/.tsbuildinfo",
8+
"emitDeclarationOnly": true,
79
"lib": ["DOM", "ESNext"],
810
"noImplicitReturns": false,
911
"skipLibCheck": true,

0 commit comments

Comments
 (0)