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 all 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
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ on:
- 'scripts'
- 'patches'

workflow_dispatch:

jobs:
test:
name: ${{ matrix.command }}
Expand Down Expand Up @@ -98,7 +100,7 @@ jobs:
needs:
- test
if: ${{ github.event_name == 'push' && failure() }}

steps:
- name: Notify
uses: nobrayner/discord-webhook@v1
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,5 @@ packages/plate/docs/
/test-results/
/playwright-report/
/playwright/.cache/
.turbo
.turbo
.vercel
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This document will provide guidance to help streamline the process and make effi
This repository is a monorepo.

- We use [yarn](https://yarnpkg.com/en/docs/install) and [`workspaces`](https://yarnpkg.com/features/workspaces) for development.
- We use [Rollup](https://rollupjs.org/) as our build system.
- We use [tsup](https://tsup.egoist.dev/) as our build system.
- We use [changesets](https://github.com/changesets/changesets) for managing releases.

## Structure
Expand All @@ -32,7 +32,7 @@ packages
```

| Path | Description |
|---------------------------|------------------------------------------|
| ------------------------- | ---------------------------------------- |
| `apps/www/content` | The content for the website. |
| `apps/www/src/app` | The Next.js application for the website. |
| `apps/www/src/components` | The React components for the website. |
Expand Down Expand Up @@ -265,4 +265,4 @@ After creating your package, install and build it:
```bash
yarn install
yarn build
```
```
155 changes: 88 additions & 67 deletions apps/www/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,77 +1,98 @@
// import { createContentlayerPlugin } from 'next-contentlayer';

/** @type {import('next').NextConfig} */
const nextConfig = {
// Enable React strict mode.
// https://nextjs.org/docs/api-reference/next.config.js/react-strict-mod
reactStrictMode: true,
const nextConfig = async (phase, { defaultConfig }) => {
/**
* @type {import('next').NextConfig}
*/
const config = {
// Enable React strict mode.
// https://nextjs.org/docs/api-reference/next.config.js/react-strict-mod
reactStrictMode: true,

// Configure domains to allow for optimized image loading.
// https://nextjs.org/docs/basic-features/image-optimization#domains
images: {
domains: [
'cdn.discordapp.com',
'lh3.googleusercontent.com',
'avatars.githubusercontent.com',
],
},
// Configure domains to allow for optimized image loading.
// https://nextjs.org/docs/basic-features/image-optimization#domains
images: {
domains: [
'cdn.discordapp.com',
'lh3.googleusercontent.com',
'avatars.githubusercontent.com',
],
},

// typescript: {
// ignoreBuildErrors: true,
// },
// eslint: {
// ignoreDuringBuilds: true,
// },
// typescript: {
// ignoreBuildErrors: true,
// },
// eslint: {
// ignoreDuringBuilds: true,
// },

staticPageGenerationTimeout: 1200,
staticPageGenerationTimeout: 1200,

// Enable experimental features.
experimental: {
esmExternals: false,
serverActions: true,
// Specify external packages that should be excluded from server-side rendering.
// https://beta.nextjs.org/docs/api-reference/next-config#servercomponentsexternalpackages
serverComponentsExternalPackages: ['@prisma/client'],
},
// Enable experimental features.
experimental: {
esmExternals: false,
serverActions: true,
// Specify external packages that should be excluded from server-side rendering.
// https://beta.nextjs.org/docs/api-reference/next-config#servercomponentsexternalpackages
serverComponentsExternalPackages: ['@prisma/client'],
},

// redirects() {
// return [
// {
// source: '/components',
// destination: '/docs/components/accordion',
// permanent: true,
// },
// {
// source: '/docs/components',
// destination: '/docs/components/accordion',
// permanent: true,
// },
// {
// source: '/examples',
// destination: '/examples/dashboard',
// permanent: false,
// },
// {
// source: '/docs/primitives/:path*',
// destination: '/docs/components/:path*',
// permanent: true,
// },
// {
// source: '/figma',
// destination: '/docs/figma',
// permanent: true,
// },
// {
// source: '/docs/forms',
// destination: '/docs/forms/react-hook-form',
// permanent: false,
// },
// ];
// },
};
// redirects() {
// return [
// {
// source: '/components',
// destination: '/docs/components/accordion',
// permanent: true,
// },
// {
// source: '/docs/components',
// destination: '/docs/components/accordion',
// permanent: true,
// },
// {
// source: '/examples',
// destination: '/examples/dashboard',
// permanent: false,
// },
// {
// source: '/docs/primitives/:path*',
// destination: '/docs/components/:path*',
// permanent: true,
// },
// {
// source: '/figma',
// destination: '/docs/figma',
// permanent: true,
// },
// {
// source: '/docs/forms',
// destination: '/docs/forms/react-hook-form',
// permanent: false,
// },
// ];
// },
};
if (phase === 'phase-development-server') {
const fs = await import('node:fs');
const glob = await import('glob').then((mod) => mod.default);

const packageNames = new glob.GlobSync(
'../../packages/**/package.json'
).found
.map((file) => {
try {
const packageJson = JSON.parse(fs.readFileSync(file, 'utf8'));
return packageJson.name;
} catch (error) {
return null;
}
})
.filter((pkg) => pkg?.startsWith('@udecode'));

// const withContentlayer = createContentlayerPlugin({
// Additional Contentlayer config options
// });
config.transpilePackages = packageNames;
}

return config;
};

export default nextConfig;
33 changes: 33 additions & 0 deletions config/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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((opts) => {
return {
...opts,
entry: [INPUT_FILE],
format: ['cjs', 'esm'],
external: [],
skipNodeModulesBundle: true,
dts: true,
sourcemap: true,
clean: true,
minify: false,
onSuccess: async () => {
if (opts.watch) {
console.info('Watching for changes...');
return;
}

console.info('Build succeeded!');
},

silent: true,
};
});
79 changes: 79 additions & 0 deletions config/turbowatch.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { readFileSync } from 'node:fs';
import { GlobSync } from 'glob';
import { defineConfig, Expression } from 'turbowatch';

const foundPackageJson = new GlobSync('packages/*/package.json').found;

type PathToPackageNameMap = Map<string, string>;

const allPackages = foundPackageJson.reduce<PathToPackageNameMap>(
(acc, current) => {
try {
const packageJson = readFileSync(current, 'utf8');
const packageJsonParsed = JSON.parse(packageJson) as {
dependencies: Record<string, string>;
name: string | undefined;
};

const packageName = packageJsonParsed.name;

if (!packageName) {
return acc;
}

acc.set(current, packageName);
return acc;
} catch (_) {}

return acc;
},
new Map()
);

const dirList = [...allPackages.keys()].map(
(dir) => ['dirname', dir.replace('/package.json', '')] satisfies Expression
);

export default defineConfig({
project: process.cwd(),
triggers: [
{
expression: [
'allof',
['not', ['anyof', ['dirname', 'node_modules'], ['dirname', 'dist']]],
['anyof', ...dirList],
[
'anyof',
['match', '*.ts', 'basename'],
['match', '*.tsx', 'basename'],
['match', '*.js', 'basename'],
],
],
interruptible: true,
name: 'build',
onChange: async ({ spawn, files, abortSignal }) => {
const changedPackages = new Set<string>();
for (const file of files) {
const pkgJsonPath = file.name
.replace(`${process.cwd()}/`, '')
.replace(/\/src\/.*/, '/package.json');

const packageName = allPackages.get(pkgJsonPath);

if (!packageName) {
continue;
}

changedPackages.add(packageName);
}

if (changedPackages.size === 0) {
return;
}

await spawn`turbo run build --filter=${[...changedPackages].join(',')}`;
if (abortSignal?.aborted) return;
},
},
],
});
Loading
Loading