Skip to content

chore: upgrade esbuild and migrate to rollup #6329

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

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@typescript-eslint/parser": "^5.8.1",
"conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3",
"esbuild": "0.14.3",
"esbuild": "^0.14.9",
"eslint": "^8.5.0",
"eslint-define-config": "^1.2.1",
"eslint-plugin-node": "^11.1.0",
Expand Down
7 changes: 6 additions & 1 deletion packages/plugin-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"dev": "tsc -p . -w --incremental",
"build": "rimraf dist && run-s build-bundle build-types",
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@babel/* --external:@rollup/* --external:resolve --external:react-refresh/* --outfile=dist/index.js",
"build-bundle": "rollup -c",
"build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-react",
"release": "ts-node ../../scripts/release.ts"
Expand All @@ -41,5 +41,10 @@
"@rollup/pluginutils": "^4.1.2",
"react-refresh": "^0.11.0",
"resolve": "^1.20.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "13.1.1",
"@rollup/plugin-typescript": "^8.3.0"
}
}
53 changes: 53 additions & 0 deletions packages/plugin-react/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import path from 'path'
import nodeResolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import commonjs from '@rollup/plugin-commonjs'

/**
*
* @param {boolean} isProduction
* @returns {import('rollup').RollupOptions}
*/
const createNodeConfig = (isProduction) => {
/**
* @type { import('rollup').RollupOptions }
*/
const nodeConfig = {
input: path.resolve(__dirname, 'src/index.ts'),
output: [
{
file: path.resolve(__dirname, 'dist/index.js'),
inlineDynamicImports: true,
exports: 'named',
format: 'commonjs',
externalLiveBindings: false,
freeze: false
}
],
external: [...Object.keys(require('./package.json').dependencies)],
plugins: [
nodeResolve({ preferBuiltins: true }),
typescript({
tsconfig: 'tsconfig.json',
module: 'esnext',
target: 'es2019',
include: ['src/**/*.ts'],
esModuleInterop: true
}),
commonjs({
extensions: ['.js'],
transformMixedEsModules: true,
requireReturnsDefault: true
})
]
}

return nodeConfig
}

export default (commandLineArgs) => {
const isDev = commandLineArgs.watch
const isProduction = !isDev

return [createNodeConfig(isProduction)]
}
9 changes: 6 additions & 3 deletions packages/plugin-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"dev": "rimraf dist && run-p dev-types dev-watch",
"dev": "rimraf dist && rollup -c -w",
"dev-types": "tsc -p . -w --incremental --emitDeclarationOnly",
"dev-watch": "esbuild src/index.ts --watch --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js",
"build": "rimraf dist && run-s build-bundle build-types",
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js",
"build-bundle": "rollup -c",
"build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-vue",
"release": "ts-node ../../scripts/release.ts"
Expand All @@ -35,11 +35,14 @@
"vue": "^3.2.25"
},
"devDependencies": {
"rollup": "^2.59.0",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "13.1.1",
"@rollup/plugin-typescript": "^8.3.0",
"@rollup/pluginutils": "^4.1.2",
"@types/hash-sum": "^1.0.0",
"debug": "^4.3.3",
"hash-sum": "^2.0.0",
"rollup": "^2.59.0",
"slash": "^4.0.0",
"source-map": "^0.6.1",
"vue": "^3.2.26"
Expand Down
49 changes: 49 additions & 0 deletions packages/plugin-vue/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import path from 'path'
import nodeResolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import commonjs from '@rollup/plugin-commonjs'

/**
*
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't need this blank line

* @param {boolean} isProduction
* @returns {import('rollup').RollupOptions}
*/
const createNodeConfig = (isProduction) => {
/**
* @type { import('rollup').RollupOptions }
*/
const nodeConfig = {
input: path.resolve(__dirname, 'src/index.ts'),
output: [
{
file: path.resolve(__dirname, 'dist/index.js'),
exports: 'named',
format: 'commonjs',
freeze: false
}
],
external: ['vite', 'vue/compiler-sfc'],
plugins: [
nodeResolve({ preferBuiltins: true }),
typescript({
tsconfig: 'tsconfig.json',
module: 'esnext',
target: 'es2019',
include: ['src/**/*.ts'],
esModuleInterop: true
}),
commonjs({
extensions: ['.js']
})
]
}

return nodeConfig
}

export default (commandLineArgs) => {
const isDev = commandLineArgs.watch
const isProduction = !isDev

return [createNodeConfig(isProduction)]
}
3 changes: 2 additions & 1 deletion packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export interface ResolvedOptions extends Options {
devServer?: ViteDevServer
}

export default function vuePlugin(rawOptions: Options = {}): Plugin {
export default vuePlugin
function vuePlugin(rawOptions: Options = {}): Plugin {
const {
include = /\.vue$/,
exclude,
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
"dependencies": {
"esbuild": "0.14.3",
"esbuild": "^0.14.9",
"json5": "^2.2.0",
"postcss": "^8.4.5",
"resolve": "^1.20.0",
Expand Down
Loading