diff --git a/.changeset/five-roses-taste.md b/.changeset/five-roses-taste.md new file mode 100644 index 00000000..ba0c9b34 --- /dev/null +++ b/.changeset/five-roses-taste.md @@ -0,0 +1,5 @@ +--- +"r18gs": patch +--- + +Test if Next.js app router works when useRGS is exported as named export diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 00000000..242cefe6 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,20 @@ +{ + "mode": "exit", + "tag": "alpha", + "initialVersions": { + "@example/nextjs": "0.0.0", + "@example/remix": "0.0.0", + "@example/vite": "0.0.0", + "r18gs": "1.1.2-alpha.0", + "@repo/eslint-config": "0.0.0", + "@repo/typescript-config": "0.0.0", + "@repo/jest-presets": "0.0.0", + "@repo/logger": "0.0.0", + "@repo/shared": "0.0.1-alpha.0", + "@repo/scripts": "0.0.0" + }, + "changesets": [ + "five-roses-taste", + "tall-oranges-sort" + ] +} diff --git a/.changeset/tall-oranges-sort.md b/.changeset/tall-oranges-sort.md new file mode 100644 index 00000000..fae1b70f --- /dev/null +++ b/.changeset/tall-oranges-sort.md @@ -0,0 +1,5 @@ +--- +"r18gs": patch +--- + +Add minify plugin diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index 5cb32d76..af7fbee9 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -1,5 +1,17 @@ # r18gs +## 1.1.2-alpha.1 + +### Patch Changes + +- cad3c42: Add minify plugin + +## 1.1.2-alpha.0 + +### Patch Changes + +- 46b9218: Test if Next.js app router works when useRGS is exported as named export + ## 1.1.1 ### Patch Changes diff --git a/lib/package.json b/lib/package.json index 1c7a3651..45227948 100644 --- a/lib/package.json +++ b/lib/package.json @@ -2,7 +2,7 @@ "name": "r18gs", "author": "Mayank Kumar Chaudhari ", "private": false, - "version": "1.1.1", + "version": "1.1.2-alpha.1", "description": "A simple yet elegant, light weight, react18 global store to replace Zustand for better tree shaking.", "license": "MPL-2.0", "main": "./dist/index.js", diff --git a/lib/src/index.ts b/lib/src/index.ts index cfb4b274..3c784200 100644 --- a/lib/src/index.ts +++ b/lib/src/index.ts @@ -34,5 +34,6 @@ const useRGS = (key: string, value?: ValueType): [T, SetStateAction] => return createHook(key); }; +/** @deprecated - default export is deprecated and will be removed. Use `import { useRGS } from "r18gs"` */ export default useRGS; export { useRGS }; diff --git a/lib/tsup.config.ts b/lib/tsup.config.ts index c09a8bc1..f36865bd 100644 --- a/lib/tsup.config.ts +++ b/lib/tsup.config.ts @@ -1,18 +1,44 @@ -import { defineConfig, type Options } from "tsup"; -import react18Plugin from "esbuild-plugin-react18"; -import cssPlugin from "esbuild-plugin-react18-css"; +import { defineConfig } from "tsup"; +import fs from "node:fs"; -export default defineConfig( - (options: Options) => - ({ - format: ["cjs", "esm"], - target: "es2019", - entry: ["./src"], - sourcemap: false, - clean: !options.watch, - bundle: true, - minify: !options.watch, - esbuildPlugins: [react18Plugin(), cssPlugin({ generateScopedName: "[folder]__[local]" })], - ...options, - }) as Options, -); +export default defineConfig(options => ({ + format: ["cjs", "esm"], + target: "es2015", + entry: ["./src"], + sourcemap: false, + clean: !options.watch, + bundle: true, + minify: !options.watch, + esbuildPlugins: [ + { + name: "improve-minify", + setup(build) { + build.onLoad({ filter: /utils.ts/ }, args => { + let contents = fs.readFileSync(args.path, "utf8"); + const lines = contents.split("\n"); + const hackLine = lines.find(line => line.startsWith("const [VALUE,")); + + if (!hackLine) return { contents, loader: "ts" }; + /** remove hackLine */ + contents = contents.replace(hackLine, ""); + + /** clean up */ + const tokens = hackLine + .replace("const", "") + .split("=")[0] + .trim() + .replace(/\]|\[/g, "") + .split(",") + .map((t, i) => ({ token: t.trim(), i })); + + tokens.sort((a, b) => b.token.length - a.token.length); + + for (const t of tokens) { + contents = contents.replace(new RegExp(`${t.token}`, "g"), String(t.i)); + } + return { contents, loader: "ts" }; + }); + }, + }, + ], +})); diff --git a/packages/shared/CHANGELOG.md b/packages/shared/CHANGELOG.md new file mode 100644 index 00000000..989c34e7 --- /dev/null +++ b/packages/shared/CHANGELOG.md @@ -0,0 +1,15 @@ +# @repo/shared + +## 0.0.1-alpha.1 + +### Patch Changes + +- Updated dependencies [cad3c42] + - r18gs@1.1.2-alpha.1 + +## 0.0.1-alpha.0 + +### Patch Changes + +- Updated dependencies [46b9218] + - r18gs@1.1.2-alpha.0 diff --git a/packages/shared/package.json b/packages/shared/package.json index 2c6e18c1..ad61cc05 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@repo/shared", - "version": "0.0.0", + "version": "0.0.1-alpha.1", "private": true, "sideEffects": false, "main": "./dist/index.js", diff --git a/scripts/publish.js b/scripts/publish.js index 13b414e8..0806b48c 100644 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -46,3 +46,21 @@ execSync("cd lib && pnpm build && npm publish --provenance --access public"); execSync( `gh release create ${VERSION} --generate-notes --latest -n "$(sed '1,/^## /d;/^## /,$d' CHANGELOG.md)" --title "Release v${VERSION}"`, ); + +// Publish canonical packages +[ + "@mayank1513/r18gs", + "react18-global-store", + "react18-store", + "react19-global-store", + "react19-store", + "r19gs", +].forEach(pkg => { + execSync(`sed -i -e "s/name.*/name\\": \\"${pkg}\\",/" lib/package.json`); + execSync("cd lib && npm publish --provenance --access public"); +}); + +// Mark deprecated +execSync( + 'npm deprecate @mayank1513/r18gs "Please use https://www.npmjs.com/package/r18gs instead. We initially created scoped packages to have similarities with the GitHub Public Repository (which requires packages to be scoped). We are no longer using GPR and thus deprecating all scoped packages for which corresponding un-scoped packages exist."', +);