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

[Enhance] Add cache busting when shared package's changed #585

Merged
merged 20 commits into from
Jul 20, 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
4 changes: 2 additions & 2 deletions chrome-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"clean": "rimraf ../../dist",
"build": "tsc --noEmit && vite build",
"build:firefox": "tsc --noEmit && cross-env __FIREFOX__=true vite build",
"build:watch": "cross-env __DEV__=true vite build -w --mode development",
"build:firefox:watch": "cross-env __DEV__=true __FIREFOX__=true vite build -w --mode development",
"build:watch": "cross-env __DEV__=true vite build --mode development",
"build:firefox:watch": "cross-env __DEV__=true __FIREFOX__=true vite build --mode development",
"dev": "pnpm build:watch",
"dev:firefox": "pnpm build:firefox:watch",
"test": "vitest run",
Expand Down
3 changes: 2 additions & 1 deletion chrome-extension/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { resolve } from 'path';
import libAssetsPlugin from '@laynezh/vite-plugin-lib-assets';
import makeManifestPlugin from './utils/plugins/make-manifest-plugin';
import { watchPublicPlugin, watchRebuildPlugin } from '@chrome-extension-boilerplate/hmr';
import { isDev, isProduction } from '@chrome-extension-boilerplate/vite-config';
import { isDev, isProduction, watchOption } from '@chrome-extension-boilerplate/vite-config';

const rootDir = resolve(__dirname);
const libDir = resolve(rootDir, 'lib');
Expand Down Expand Up @@ -38,6 +38,7 @@ export default defineConfig({
sourcemap: isDev,
minify: isProduction,
reportCompressedSize: isProduction,
watch: watchOption,
rollupOptions: {
external: ['chrome'],
},
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@typescript-eslint/parser": "^7.16.0",
"autoprefixer": "^10.4.19",
"cross-env": "^7.0.3",
"esbuild": "^0.23.0",
"eslint": "8.56.0",
"eslint-config-airbnb-typescript": "18.0.0",
"eslint-config-prettier": "9.1.0",
Expand All @@ -54,7 +55,7 @@
"rimraf": "^6.0.1",
"tailwindcss": "^3.4.4",
"tslib": "^2.6.3",
"turbo": "^2.0.6",
"turbo": "^2.0.9",
"typescript": "5.5.3",
"vite": "5.3.3"
},
Expand All @@ -63,7 +64,7 @@
"prettier --write"
]
},
"packageManager": "pnpm@9.5.0",
"packageManager": "pnpm@9.5.0",
"engines": {
"node": ">=18.12.0"
}
Expand Down
15 changes: 15 additions & 0 deletions packages/shared/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as esbuild from "esbuild"

/**
* @type { import("esbuild").BuildOptions }
*/
const buildOptions = {
entryPoints: ["./index.ts", "./lib/**/*.ts", "./lib/**/*.tsx"],
tsconfig: "./tsconfig.json",
bundle: false,
target: 'es6',
outdir: "./dist",
sourcemap: true,
}

await esbuild.build(buildOptions);
7 changes: 2 additions & 5 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
"files": [
"dist/**"
],
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "index.ts",
"main": "./dist/index.js",
"scripts": {
"clean": "rimraf ./dist",
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs",
"ready": "pnpm build:esm && pnpm build:cjs",
"ready": "node build.mjs",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
"prettier": "prettier . --write --ignore-path ../../.prettierignore",
Expand Down
18 changes: 18 additions & 0 deletions packages/ui/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as esbuild from "esbuild"
import * as fs from "fs";
import { resolve } from "node:path";

/**
* @type { import("esbuild").BuildOptions }
*/
const buildOptions = {
entryPoints: ["./index.ts","./tailwind.config.ts", "./lib/**/*.ts", "./lib/**/*.tsx"],
tsconfig: "./tsconfig.json",
bundle: false,
target: 'es6',
outdir: "./dist",
sourcemap: true,
}

await esbuild.build(buildOptions);
fs.copyFileSync(resolve("lib", "global.css"),resolve("dist", "global.css"))
8 changes: 2 additions & 6 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@
"dist/global.css"
],
"types": "index.ts",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"main": "./dist/index.js",
"scripts": {
"clean": "rimraf ./dist && rimraf .turbo",
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs",
"cp:css": "cp ./lib/global.css ./dist/global.css",
"ready": "pnpm build:esm && pnpm build:cjs && pnpm cp:css",
"ready": "node build.mjs",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
"prettier": "prettier . --write",
Expand Down
10 changes: 10 additions & 0 deletions packages/vite-config/lib/withPageConfig.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import react from '@vitejs/plugin-react-swc';
import deepmerge from 'deepmerge';
import { isDev, isProduction } from './env.mjs';

export const watchOption = isDev ? {
buildDelay: 50,
chokidar: {
ignored:[
/\/packages\/.*\.(ts|tsx|map)$/,
]
}
}: undefined;

/**
* @typedef {import('vite').UserConfig} UserConfig
* @param {UserConfig} config
Expand All @@ -20,6 +29,7 @@ export function withPageConfig(config) {
minify: isProduction,
reportCompressedSize: isProduction,
emptyOutDir: true,
watch: watchOption,
rollupOptions: {
external: ['chrome'],
},
Expand Down
4 changes: 2 additions & 2 deletions pages/content-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"scripts": {
"clean": "rimraf ./dist",
"build:tailwindcss": "tailwindcss -i src/tailwind-input.css -o src/tailwind-output.css",
"build": "pnpm clean && pnpm type-check && pnpm build:tailwindcss && vite build",
"build:watch": "cross-env __DEV__=true vite build -w --mode development & pnpm build:tailwindcss -- --watch",
"build": "pnpm run clean && pnpm type-check && pnpm build:tailwindcss && vite build",
"build:watch": "cross-env __DEV__=true vite build --mode development & pnpm build:tailwindcss -- --watch",
"dev": "pnpm build:watch",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
Expand Down
4 changes: 2 additions & 2 deletions pages/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"scripts": {
"clean": "rimraf ./dist",
"build": "pnpm clean && pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build -w --mode development",
"build": "pnpm run clean&& pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build --mode development",
"dev": "pnpm build:watch",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
Expand Down
4 changes: 2 additions & 2 deletions pages/devtools-panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"scripts": {
"clean": "rimraf ./dist",
"build": "pnpm clean && pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build -w --mode development",
"build": "pnpm run clean&& pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build --mode development",
"dev": "pnpm build:watch",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
Expand Down
4 changes: 2 additions & 2 deletions pages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"scripts": {
"clean": "rimraf ./dist",
"build": "pnpm clean && pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build -w --mode development",
"build": "pnpm run clean && pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build --mode development",
"dev": "pnpm build:watch",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
Expand Down
4 changes: 2 additions & 2 deletions pages/new-tab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"scripts": {
"clean": "rimraf ./dist",
"build": "pnpm clean && pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build -w --mode development",
"build": "pnpm run clean&& pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build --mode development",
"dev": "pnpm build:watch",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
Expand Down
4 changes: 2 additions & 2 deletions pages/options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"scripts": {
"clean": "rimraf ./dist",
"build": "pnpm clean && pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build -w --mode development",
"build": "pnpm run clean&& pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build --mode development",
"dev": "pnpm build:watch",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
Expand Down
4 changes: 2 additions & 2 deletions pages/popup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"scripts": {
"clean": "rimraf ./dist",
"build": "pnpm clean && pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build -w --mode development",
"build": "pnpm run clean&& pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build --mode development",
"dev": "pnpm build:watch",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
Expand Down
4 changes: 2 additions & 2 deletions pages/side-panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"scripts": {
"clean": "rimraf ./dist",
"build": "pnpm clean && pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build -w --mode development",
"build": "pnpm run clean&& pnpm type-check && vite build",
"build:watch": "cross-env __DEV__=true vite build --mode development",
"dev": "pnpm build:watch",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
Expand Down
Loading