refactor(repo): use turbo + rollup + vite
This commit is contained in:
13
tooling/eslint-config/package.json
Normal file
13
tooling/eslint-config/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "@reactflow/eslint-config",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"main": "src/index.js",
|
||||
"devDependencies": {
|
||||
"eslint": "^8.22.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-config-turbo": "latest",
|
||||
"eslint-plugin-react": "latest"
|
||||
}
|
||||
}
|
||||
32
tooling/eslint-config/src/index.js
Normal file
32
tooling/eslint-config/src/index.js
Normal file
@@ -0,0 +1,32 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
node: true,
|
||||
},
|
||||
parser: '@typescript-eslint/parser',
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:react/recommended',
|
||||
'plugin:react/jsx-runtime',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'turbo',
|
||||
'prettier',
|
||||
],
|
||||
plugins: ['react', '@typescript-eslint'],
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
},
|
||||
};
|
||||
8
tooling/postcss-config/index.js
Normal file
8
tooling/postcss-config/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
plugins: [
|
||||
require('postcss-nested'),
|
||||
require('postcss-combine-duplicated-selectors'),
|
||||
require('autoprefixer'),
|
||||
require('postcss-import'),
|
||||
],
|
||||
};
|
||||
19
tooling/rollup-config/package.json
Normal file
19
tooling/rollup-config/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@reactflow/rollup-config",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"main": "src/index.js",
|
||||
"module": "src/index.js",
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^22.0.2",
|
||||
"@rollup/plugin-node-resolve": "^14.0.1",
|
||||
"@rollup/plugin-replace": "^4.0.0",
|
||||
"rollup": "^2.79.0",
|
||||
"rollup-plugin-peer-deps-external": "^2.2.4",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"rollup-plugin-typescript2": "^0.33.0",
|
||||
"typescript": "^4.7.4"
|
||||
}
|
||||
}
|
||||
77
tooling/rollup-config/src/index.js
Normal file
77
tooling/rollup-config/src/index.js
Normal file
@@ -0,0 +1,77 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { cwd } from 'process';
|
||||
import { defineConfig } from 'rollup';
|
||||
import resolvePlugin from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import replace from '@rollup/plugin-replace';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
||||
import typescript from 'rollup-plugin-typescript2';
|
||||
|
||||
const pkg = JSON.parse(readFileSync(resolve(cwd(), './package.json')));
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
|
||||
const defaultPlugins = [
|
||||
resolvePlugin(),
|
||||
commonjs({
|
||||
include: /node_modules/,
|
||||
}),
|
||||
];
|
||||
|
||||
const onwarn = (warning, rollupWarn) => {
|
||||
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
|
||||
rollupWarn(warning);
|
||||
}
|
||||
};
|
||||
|
||||
export const esmConfig = defineConfig({
|
||||
input: pkg.source,
|
||||
output: {
|
||||
file: pkg.module,
|
||||
format: 'esm',
|
||||
},
|
||||
onwarn,
|
||||
plugins: [
|
||||
peerDepsExternal({
|
||||
includeDependencies: true,
|
||||
}),
|
||||
...defaultPlugins,
|
||||
typescript({
|
||||
clean: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const globals = {
|
||||
react: 'React',
|
||||
'react-dom': 'ReactDOM',
|
||||
'react/jsx-runtime': 'jsxRuntime',
|
||||
...(pkg.rollup?.globals || {}),
|
||||
};
|
||||
|
||||
export const umdConfig = defineConfig({
|
||||
input: pkg.source,
|
||||
output: {
|
||||
file: pkg.main,
|
||||
format: 'umd',
|
||||
exports: 'named',
|
||||
name: 'ReactFlow',
|
||||
globals,
|
||||
},
|
||||
onwarn,
|
||||
plugins: [
|
||||
peerDepsExternal(),
|
||||
...defaultPlugins,
|
||||
typescript({
|
||||
clean: true
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||
}),
|
||||
terser(),
|
||||
],
|
||||
});
|
||||
|
||||
export default isProd ? [esmConfig, umdConfig] : esmConfig;
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "tsconfig",
|
||||
"name": "@reactflow/tsconfig",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"license": "MIT"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"jsx": "react-jsx",
|
||||
"lib": ["dom", "esnext"],
|
||||
"module": "esnext",
|
||||
"target": "es6"
|
||||
"target": "esnext",
|
||||
"outDir": "dist"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user