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

Upgrade esbuild-loader and @craco/craco #73

Merged
merged 7 commits into from
Mar 12, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/long-dragons-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'craco-esbuild': minor
---

Updated esbuild-loader to v4 and craco to v7.
16 changes: 8 additions & 8 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v2

- uses: pnpm/action-setup@v2
with:
version: 6.24.1
version: 8.15.1

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
Expand All @@ -33,25 +33,25 @@ jobs:

- name: Compile create-react-app examples using react-scripts
run: |
pnpm run build-react-scripts --filter "with-*"
pnpm run --filter "with-*" build-react-scripts

- name: Test create-react-app examples using react-scripts
run: |
pnpm run test-react-scripts --filter "with-*"
pnpm run --filter "with-*" test-react-scripts

test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v2

- uses: pnpm/action-setup@v2
with:
version: 6.24.1
version: 8.15.1

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
Expand All @@ -64,8 +64,8 @@ jobs:

- name: Compile create-react-app examples using craco
run: |
pnpm run build --filter "with-*"
pnpm run --filter "with-*" build

- name: Test create-react-app examples using craco
run: |
pnpm run test --filter "with-*"
pnpm run --filter "with-*" test
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:

- uses: pnpm/action-setup@v2
with:
version: 6.24.1
version: 8.15.1

- name: Use Node.js 16.x
- name: Use Node.js 20.x
uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: 20.x
cache: 'pnpm'

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpx lint-staged
pnpm lint-staged
5 changes: 3 additions & 2 deletions examples/with-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@craco/craco": "6.4.3",
"@testing-library/jest-dom": "^5.16.1",
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"@craco/craco": "7.0.0",
"@testing-library/jest-dom": "^6.3.0",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"craco-esbuild": "workspace:craco-esbuild",
Expand Down
4 changes: 2 additions & 2 deletions examples/with-svgr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@craco/craco": "6.4.3",
"@testing-library/jest-dom": "^5.16.1",
"@craco/craco": "7.0.0",
"@testing-library/jest-dom": "^6.3.0",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"craco-esbuild": "workspace:craco-esbuild",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions examples/with-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@craco/craco": "6.4.3",
"@testing-library/jest-dom": "^5.16.1",
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"@craco/craco": "7.0.0",
"@testing-library/jest-dom": "^6.3.0",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.4.0",
"@types/node": "^16.11.15",
"@types/jest": "^28.0.0",
"@types/node": "^18.19.18",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"craco-esbuild": "workspace:craco-esbuild",
Expand Down
3 changes: 2 additions & 1 deletion examples/with-typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"jsx": "react-jsx",
"types": ["jest", "@testing-library/jest-dom"]
},
"include": ["src"]
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"prettier": {
"singleQuote": true
},
"engines" : {
"node": ">=18.0.0"
},
"lint-staged": {
"*.{js,ts,tsx,css,scss,json,md,mdx,yml}": [
"prettier --write",
Expand Down
6 changes: 3 additions & 3 deletions packages/craco-esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"src"
],
"peerDependencies": {
"@craco/craco": "^6.0.0 || ^7.0.0 || ^7.0.0-alpha",
"@craco/craco": "^^7.0.0",
"react-scripts": "^5.0.0"
},
"dependencies": {
"esbuild-jest": "0.5.0",
"esbuild-loader": "^2.18.0"
"esbuild-loader": "^4.0.1"
},
"devDependencies": {
"@craco/craco": "6.4.3",
"@craco/craco": "7.0.0",
Copy link
Owner

Choose a reason for hiding this comment

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

let's use the latest craco version here?

"react-scripts": "5.0.0"
}
}
7 changes: 2 additions & 5 deletions packages/craco-esbuild/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const fs = require('fs');
const { loaderByName, removeLoaders, addAfterLoader } = require('@craco/craco');
const { ESBuildMinifyPlugin } = require('esbuild-loader');
const { EsbuildPlugin } = require('esbuild-loader');

const removeMinimizer = (webpackConfig, name) => {
const idx = webpackConfig.optimization.minimizer.findIndex(
Expand All @@ -25,7 +24,6 @@ module.exports = {
pluginOptions,
context: { paths },
}) => {
const useTypeScript = fs.existsSync(paths.appTsConfig);
const esbuildLoaderOptions =
pluginOptions && pluginOptions.esbuildLoaderOptions;

Expand All @@ -42,7 +40,6 @@ module.exports = {
options: esbuildLoaderOptions
? esbuildLoaderOptions
: {
loader: useTypeScript ? 'tsx' : 'jsx',
target: 'es2015',
},
});
Expand All @@ -58,7 +55,7 @@ module.exports = {
replaceMinimizer(
webpackConfig,
'TerserPlugin',
new ESBuildMinifyPlugin(minimizerOptions)
new EsbuildPlugin(minimizerOptions)
);
// remove the css OptimizeCssAssetsWebpackPlugin
if (minimizerOptions.css) {
Expand Down
Loading
Loading