Skip to content

Commit

Permalink
docs(changeset): refactor: replaced babel with swc
Browse files Browse the repository at this point in the history
  • Loading branch information
DuCanhGH committed Dec 22, 2022
1 parent f9ae953 commit b6f10be
Show file tree
Hide file tree
Showing 20 changed files with 398 additions and 483 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-ways-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ducanh2912/next-pwa": minor
---

refactor: replaced babel with swc
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 ShadowWalker [email protected] https://weiw.io
Copyright (c) 2019 ShadowWalker [email protected] https://weiw.io, 2022 DuCanhGH (fork version)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.0.7",
"next": "13.1.0",
"react": "18.2.0",
"react-dom": "18.2.0"
},
Expand All @@ -20,7 +20,7 @@
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"eslint-config-next": "13.1.0",
"typescript": "4.9.4"
}
}
5 changes: 2 additions & 3 deletions examples/cookie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"cookies-next": "2.1.1",
"next": "13.0.7",
"next": "13.1.0",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@types/node": "18.11.17",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"eslint-config-next": "13.1.0",
"typescript": "4.9.4",
"webpack": "5.75.0"
}
Expand Down
7 changes: 3 additions & 4 deletions examples/custom-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@
"@fastify/compress": "6.2.0",
"cross-env": "7.0.3",
"fastify": "4.10.2",
"next": "13.0.7",
"next": "13.1.0",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@swc/core": "1.3.23",
"@swc/core": "1.3.24",
"@types/node": "18.11.17",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"eslint-config-next": "13.1.0",
"nodemon": "2.0.20",
"rimraf": "3.0.2",
"ts-node": "10.9.1",
Expand Down
6 changes: 2 additions & 4 deletions examples/custom-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"babel-loader": "9.1.0",
"next": "13.0.7",
"next": "13.1.0",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@types/node": "18.11.17",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"eslint-config-next": "13.1.0",
"typescript": "4.9.4",
"webpack": "5.75.0"
}
Expand Down
5 changes: 2 additions & 3 deletions examples/lifecycle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.0.7",
"next": "13.1.0",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@types/node": "18.11.17",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"eslint-config-next": "13.1.0",
"typescript": "4.9.4",
"webpack": "5.75.0"
}
Expand Down
7 changes: 3 additions & 4 deletions examples/next-i18next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@
"cross-env": "7.0.3",
"express": "4.18.2",
"fastify-compress": "4.1.0",
"i18next": "22.4.5",
"next": "13.0.7",
"i18next": "22.4.6",
"next": "13.1.0",
"next-i18next": "13.0.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-i18next": "12.1.1"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@types/node": "18.11.17",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"eslint-config-next": "13.1.0",
"typescript": "4.9.4",
"webpack": "5.75.0"
}
Expand Down
5 changes: 2 additions & 3 deletions examples/next-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.0.7",
"next": "13.1.0",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@types/node": "18.11.17",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"eslint-config-next": "13.1.0",
"typescript": "4.9.4",
"webpack": "5.75.0"
}
Expand Down
7 changes: 3 additions & 4 deletions examples/offline-fallback-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.0.7",
"next": "13.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"sharp": "0.31.2"
"sharp": "0.31.3"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@types/node": "18.11.17",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"eslint-config-next": "13.1.0",
"typescript": "4.9.4",
"webpack": "5.75.0"
}
Expand Down
5 changes: 2 additions & 3 deletions examples/web-push/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.0.7",
"next": "13.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"web-push": "3.5.0"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@types/node": "18.11.17",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"@types/web-push": "3.3.2",
"eslint": "8.30.0",
"eslint-config-next": "13.0.7",
"eslint-config-next": "13.1.0",
"typescript": "4.9.4",
"webpack": "5.75.0"
}
Expand Down
14 changes: 12 additions & 2 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
// @ts-check
import { ESLint } from "eslint";
import { quote } from "shell-quote";

const eslint = new ESLint();
const isWin = process.platform === "win32";

/** @type {Record<string, (_: string[]) => string[]>} */
/**
* @type {Record<
* string,
* (filenames: string[]) => string | string[] | Promise<string | string[]>
* >}
*/
export default {
"**/*.{js,jsx,cjs,mjs,ts,tsx}": (filenames) => {
const escapedFileNames = filenames
.map((filename) => `"${isWin ? filename : escapeStr([filename])}"`)
.join(" ");
return [
`eslint --fix ${filenames
.filter(async (file) => !(await eslint.isPathIgnored(file)))
.map((f) => `"${f}"`)
.join(" ")}`,
`pnpm format ${escapedFileNames}`,
`eslint --fix ${filenames}`,
`git add ${escapedFileNames}`,
];
},
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"deps:update-all": "pnpm deps -ws --root",
"dev": "turbo run dev --parallel --filter=!@next-pwa-example/*",
"examples:build": "turbo run build --filter=@next-pwa-example/*",
"examples:dev": "turbo run dev --filter=@next-pwa-example/*",
"examples:dev": "turbo run dev --parallel --filter=@next-pwa-example/*",
"examples:lint": "turbo run lint --parallel --filter=@next-pwa-example/*",
"format": "prettier --write .",
"lint": "turbo run lint --parallel --filter=!@next-pwa-example/*",
Expand All @@ -24,29 +24,29 @@
"typecheck": "turbo run typecheck"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@changesets/cli": "2.26.0",
"@ducanh2912/next-pwa": "workspace:*",
"@swc/core": "1.3.24",
"@types/node": "18.11.17",
"@types/shell-quote": "1.7.1",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"babel-loader": "9.1.0",
"@typescript-eslint/eslint-plugin": "5.47.0",
"@typescript-eslint/parser": "5.47.0",
"cross-env": "7.0.3",
"eslint": "8.30.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-simple-import-sort": "8.0.0",
"husky": "8.0.2",
"lint-staged": "13.1.0",
"next": "13.0.7",
"npm-check-updates": "16.6.0",
"next": "13.1.0",
"npm-check-updates": "16.6.2",
"prettier": "2.8.1",
"prettier-plugin-jsdoc": "0.4.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"rimraf": "3.0.2",
"shell-quote": "1.7.4",
"swc-loader": "0.2.3",
"tslib": "2.4.1",
"turbo": "1.6.3",
"typescript": "4.9.4",
Expand Down
15 changes: 8 additions & 7 deletions packages/next-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"register": [
"./dist/register.d.ts"
]
"register": [
"./dist/register.d.ts"
]
}
},
"keywords": [
Expand All @@ -45,21 +45,22 @@
"typecheck": "tsc"
},
"dependencies": {
"babel-loader": "9.1.0",
"clean-webpack-plugin": "4.0.0",
"fast-glob": "3.2.12",
"swc-loader": "0.2.3",
"terser-webpack-plugin": "5.3.6",
"workbox-build": "6.5.4",
"workbox-webpack-plugin": "6.5.4",
"workbox-window": "6.5.4"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@rollup/plugin-json": "6.0.0",
"@rollup/plugin-node-resolve": "15.0.1",
"@rollup/plugin-terser": "0.2.0",
"@rollup/plugin-terser": "0.2.1",
"@rollup/plugin-typescript": "10.0.1",
"@swc/core": "1.3.24",
"@types/node": "18.11.17",
"rollup": "3.7.5",
"rollup": "3.8.0",
"tsconfig": "workspace:*",
"typescript": "4.9.4",
"webpack": "5.75.0"
Expand Down
6 changes: 2 additions & 4 deletions packages/next-pwa/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// @ts-check
import json from "@rollup/plugin-json";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import { defineConfig } from "rollup";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
global.__filename = __filename;

const commonConfig = defineConfig({
watch: {
Expand All @@ -24,6 +21,7 @@ const plugins = [
declaration: true,
noEmit: false,
}),
json(),
...[process.env.NODE_ENV === "production" ? [terser()] : []],
];

Expand Down
24 changes: 24 additions & 0 deletions packages/next-pwa/src/.swcrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"module": {
"type": "es6",
"lazy": true,
"noInterop": true
},
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true,
"dynamicImport": true,
"decorators": false
},
"transform": {
"react": {
"runtime": "automatic"
}
},
"target": "es2022",
"loose": false
},
"minify": false
}
Loading

0 comments on commit b6f10be

Please sign in to comment.