Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert to tsup #2652

Merged
merged 33 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2095d1f
convert to tsup
shahriar-shojib Sep 28, 2023
694a1e7
added changeset
shahriar-shojib Sep 28, 2023
1a0b367
removed unnecessary tsup options
shahriar-shojib Sep 28, 2023
cc00a3e
[test] don't use turbo cache on ci
shahriar-shojib Sep 28, 2023
b217649
[test] allow manual workflow runs
shahriar-shojib Sep 28, 2023
b9fb475
[test] update concurrency on test
shahriar-shojib Sep 28, 2023
b5d4312
[test] adjust jest concurrency
shahriar-shojib Sep 28, 2023
adf5df8
adjust concurrency for test
shahriar-shojib Sep 29, 2023
fbca0f6
test vercel deployment
shahriar-shojib Sep 29, 2023
202c544
👷 mjs
Sep 29, 2023
d60d400
rename package json rollup script to watch
shahriar-shojib Sep 29, 2023
eb1f4e8
Merge branch 'shahriar-shojib/main' of github.com:udecode/plate
shahriar-shojib Sep 29, 2023
1b87085
update tsup config
shahriar-shojib Sep 29, 2023
7791e9c
fix ts issues
shahriar-shojib Sep 29, 2023
bbbd8ed
🧪 fix import paths
Sep 29, 2023
b8be697
fix: is-hotkey imports
shahriar-shojib Sep 29, 2023
dea9b41
added custom script for global package watching
shahriar-shojib Sep 29, 2023
390c1a6
remove unused variables
shahriar-shojib Sep 29, 2023
020c5eb
use turbo to build affected packages by watch
shahriar-shojib Sep 29, 2023
71280b9
fix tests
shahriar-shojib Sep 30, 2023
d0633e1
update p:build:watch script
shahriar-shojib Sep 30, 2023
feab45a
cleanup watcher script
shahriar-shojib Sep 30, 2023
e40073b
Merge branch 'main' into main
shahriar-shojib Sep 30, 2023
75764dc
fix dev script
shahriar-shojib Sep 30, 2023
4f42820
🩹 is-hotkey
Sep 30, 2023
6b7d169
Merge branch 'main' into shahriar-shojib/main
Sep 30, 2023
2b80516
added turbowatch
shahriar-shojib Sep 30, 2023
f018b8d
Merge branch 'shahriar-shojib/main' of github.com:udecode/plate
shahriar-shojib Sep 30, 2023
6e86cb7
package json sorting
shahriar-shojib Sep 30, 2023
376a078
revert <AnyObject> changes
shahriar-shojib Sep 30, 2023
67c50a9
Merge branch 'main' into main
shahriar-shojib Sep 30, 2023
3cc78f6
remove unnecessary exports
shahriar-shojib Sep 30, 2023
a0d56f4
updated lockfile
shahriar-shojib Sep 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .changeset/chatty-lions-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
'@udecode/plate-alignment': minor
'@udecode/plate-autoformat': minor
'@udecode/plate-basic-elements': minor
'@udecode/plate-basic-marks': minor
'@udecode/plate-block-quote': minor
'@udecode/plate-break': minor
'@udecode/plate-caption': minor
'@udecode/plate-ui': minor
'@udecode/plate-cloud': minor
'@udecode/plate-code-block': minor
'@udecode/plate-combobox': minor
'@udecode/plate-comments': minor
'@udecode/plate-common': minor
'@udecode/plate-core': minor
'@udecode/plate-cursor': minor
'@udecode/plate-dnd': minor
'@udecode/plate-emoji': minor
'@udecode/plate-excalidraw': minor
'@udecode/plate-find-replace': minor
'@udecode/plate-floating': minor
'@udecode/plate-font': minor
'@udecode/plate-heading': minor
'@udecode/plate-highlight': minor
'@udecode/plate-horizontal-rule': minor
'@udecode/plate-indent': minor
'@udecode/plate-indent-list': minor
'@udecode/plate-juice': minor
'@udecode/plate-kbd': minor
'@udecode/plate-line-height': minor
'@udecode/plate-link': minor
'@udecode/plate-list': minor
'@udecode/plate-media': minor
'@udecode/plate-mention': minor
'@udecode/plate-node-id': minor
'@udecode/plate-normalizers': minor
'@udecode/plate-paragraph': minor
'@udecode/plate': minor
'@udecode/plate-utils': minor
'@udecode/plate-reset-node': minor
'@udecode/plate-resizable': minor
'@udecode/plate-select': minor
'@udecode/plate-selection': minor
'@udecode/plate-serializer-csv': minor
'@udecode/plate-serializer-docx': minor
'@udecode/plate-serializer-html': minor
'@udecode/plate-serializer-md': minor
'@udecode/slate': minor
'@udecode/slate-react': minor
'@udecode/slate-utils': minor
'@udecode/plate-suggestion': minor
'@udecode/plate-tabbable': minor
'@udecode/plate-table': minor
'@udecode/plate-test-utils': minor
'@udecode/plate-trailing-block': minor
'@udecode/utils': minor
'@udecode/plate-yjs': minor
---

use tsup as bundler
18 changes: 18 additions & 0 deletions apps/www/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
// import { createContentlayerPlugin } from 'next-contentlayer';
import fs from 'node:fs';
import glob from 'glob';

const packageNames = new glob.GlobSync('../../packages/**/package.json').found
.map((file) => {
const packageJson = JSON.parse(fs.readFileSync(file, 'utf8'));
return packageJson.name;
})
.filter((pkg) => {
if (!pkg) {
return false;
}

if (pkg.startsWith('@udecode')) {
return true;
}
});

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand Down Expand Up @@ -33,6 +50,7 @@ const nextConfig = {
// https://beta.nextjs.org/docs/api-reference/next-config#servercomponentsexternalpackages
serverComponentsExternalPackages: ['@prisma/client'],
},
transpilePackages: packageNames,

// redirects() {
// return [
Expand Down
27 changes: 27 additions & 0 deletions config/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import fs from 'node:fs';
import path from 'node:path';
import { defineConfig } from 'tsup';

const PACKAGE_ROOT_PATH = process.cwd();
const INPUT_FILE_PATH = path.join(PACKAGE_ROOT_PATH, 'src/index.ts');
const INPUT_FILE = fs.existsSync(INPUT_FILE_PATH)
? INPUT_FILE_PATH
: path.join(PACKAGE_ROOT_PATH, 'src/index.tsx');

export default defineConfig({
entry: [INPUT_FILE],
sourcemap: true,
clean: true,
format: ['cjs', 'esm'],
minify: false,
cjsInterop: true,
zbeyens marked this conversation as resolved.
Show resolved Hide resolved
dts: true,
replaceNodeEnv: true,
zbeyens marked this conversation as resolved.
Show resolved Hide resolved
skipNodeModulesBundle: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will skip bundling of anything imported that is not local to the package even if it is a dependency.
Ideally, for packages like these, I think it's best not to bundle node_module packages in the build files since it will be taken care of by the end user's bundler.
Since we're not shipping browser bundles this provides some safety in my opinion.
If you think this is unnecessary I can remove it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will test it on next release

platform: 'browser',
zbeyens marked this conversation as resolved.
Show resolved Hide resolved
outExtension: ({ format }) => {
return {
js: format === 'cjs' ? '.js' : '.es.js',
};
},
});
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
"p:brl": "cd $INIT_CWD && barrelsby -d $INIT_CWD/src -D -l all -q -e '.*(fixture|template|spec|__tests__).*'",
"p:brl:below": "cd $INIT_CWD && barrelsby -d $INIT_CWD/src -D -l below -q -e '.*(fixture|template|spec|__tests__).*'",
"p:build": "cd $INIT_CWD && yarn p:rollup && tsc",
"p:build:watch": "cd $INIT_CWD && concurrently \"yarn p:rollup -w\" \"yarn p:typecheck -w\"",
"p:build:watch": "cd $INIT_CWD && concurrently \"yarn p:rollup --watch\" \"yarn p:typecheck -w\"",
"p:clean": "cd $INIT_CWD && rimraf dist && jest --clear-cache",
"p:lint": "eslint $INIT_CWD/src --color",
"p:lint:fix": "eslint $INIT_CWD/src --color --fix",
"p:rollup": "cd $INIT_CWD && rollup -c=${PROJECT_CWD}/config/rollup.config.cjs",
"p:rollup": "cd $INIT_CWD && tsup --config=${PROJECT_CWD}/config/tsup.config.ts",
"p:test": "cd $INIT_CWD && jest --config=${PROJECT_CWD}/jest.config.cjs --passWithNoTests $INIT_CWD ",
"p:typecheck": "cd $INIT_CWD && tsc --noEmit --emitDeclarationOnly false",
"postinstall": "patch-package",
Expand Down Expand Up @@ -176,6 +176,7 @@
"slate-test-utils": "1.3.2",
"tailwindcss": "^3.3.2",
"ts-jest": "^29.1.1",
"tsup": "7.2.0",
"turbo": "^1.10.7",
"typescript": "5.1.6"
},
Expand Down
Loading