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 3 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
8 changes: 4 additions & 4 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

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

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:

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

steps:
- uses: actions/checkout@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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
with:
version: 6.24.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
4 changes: 2 additions & 2 deletions examples/with-javascript/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
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.
5 changes: 3 additions & 2 deletions examples/with-typescript/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",
"@types/jest": "^27.4.0",
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": ">=16.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 || ^7.0.0-alpha",
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 remove the alpha option there, if people use the latest version they should upgrade to craco stable

"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