Skip to content

Commit

Permalink
Merge pull request #29 from react18-tools/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
mayank1513 committed Jun 17, 2024
2 parents 83c4fb2 + a8ae74a commit 4c03608
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-roses-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"r18gs": patch
---

Test if Next.js app router works when useRGS is exported as named export
20 changes: 20 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
5 changes: 5 additions & 0 deletions .changeset/tall-oranges-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"r18gs": patch
---

Add minify plugin
12 changes: 12 additions & 0 deletions lib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "r18gs",
"author": "Mayank Kumar Chaudhari <https://mayank-chaudhari.vercel.app>",
"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",
Expand Down
1 change: 1 addition & 0 deletions lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ const useRGS = <T>(key: string, value?: ValueType<T>): [T, SetStateAction<T>] =>
return createHook<T>(key);
};

/** @deprecated - default export is deprecated and will be removed. Use `import { useRGS } from "r18gs"` */
export default useRGS;
export { useRGS };
60 changes: 43 additions & 17 deletions lib/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -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" };
});
},
},
],
}));
15 changes: 15 additions & 0 deletions packages/shared/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# @repo/shared

## 0.0.1-alpha.1

### Patch Changes

- Updated dependencies [cad3c42]
- [email protected]

## 0.0.1-alpha.0

### Patch Changes

- Updated dependencies [46b9218]
- [email protected]
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 18 additions & 0 deletions scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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."',
);

0 comments on commit 4c03608

Please sign in to comment.