Skip to content

Commit

Permalink
Merge pull request #12 from react18-tools/support-use-server
Browse files Browse the repository at this point in the history
Support module level "use server" directive
  • Loading branch information
mayank1513 authored Mar 15, 2024
2 parents 9dc21b0 + 6f1239f commit 0f910cf
Show file tree
Hide file tree
Showing 25 changed files with 331 additions and 236 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Publish to NPM
on:
push:
branches: [main]
paths: "packages/esbuild-plugin-react18/package.json"
paths: "esbuild-plugin-react18/package.json"

jobs:
publish:
Expand All @@ -19,16 +19,16 @@ jobs:

defaults:
run:
working-directory: ./packages/esbuild-plugin-react18
working-directory: ./esbuild-plugin-react18

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
registry-url: https://registry.npmjs.org
- run: npm i -g pnpm && pnpm i
name: Install dependencies
Expand Down Expand Up @@ -58,3 +58,9 @@ jobs:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.event.repository.owner.login }}
REPO: ${{ github.event.repository.name }}

- name: Mark scoped package as deprecated
run: |
npm deprecate @mayank1513/esbuild-plugin-react18 "Please use https://www.npmjs.com/package/esbuild-plugin-react18 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."
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
15 changes: 11 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- run: npm i -g pnpm && pnpm i
name: Install dependencies
- run: pnpm build --filter esbuild-plugin-react18-example
Expand All @@ -24,6 +24,13 @@ jobs:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
directory: ./packages/esbuild-plugin-react18
directory: ./esbuild-plugin-react18
token: ${{ secrets.CODECOV_TOKEN }}
flags: esbuild-plugin-react18

- uses: paambaati/[email protected]
continue-on-error: true
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: ./esbuild-plugin-react18/coverage/*.xml:clover
36 changes: 36 additions & 0 deletions .tkb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"scope": "Workspace",
"tasks": {
"task-DLMsMCnSbDOg6Q_qs3XX4": {
"id": "task-DLMsMCnSbDOg6Q_qs3XX4",
"description": "Support Sass\n- CSSPrefix --- default - ''\n- ClassName -> CSSFileName__class",
"columnId": "column-todo"
},
"QJCiT5pTHTGKydoayOOp8": {
"id": "QJCiT5pTHTGKydoayOOp8",
"description": "Breakdown into smaller functions",
"columnId": "column-done"
}
},
"columns": [
{
"id": "column-todo",
"title": "To do",
"tasksIds": [
"task-DLMsMCnSbDOg6Q_qs3XX4"
]
},
{
"id": "column-doing",
"title": "Doing",
"tasksIds": []
},
{
"id": "column-done",
"title": "Done",
"tasksIds": [
"QJCiT5pTHTGKydoayOOp8"
]
}
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"editor.wordWrap": "on",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.formatOnSaveMode": "file"
"editor.formatOnSaveMode": "file",
"mayank1513.trello-kanban.Workspace.filePath": ".tkb"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# esbuild-plugin-react18

## 0.1.0

### Minor Changes

- Support module level "use server" directive

## 0.0.7

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe.concurrent("Test plugin with ignorePatterns -- without content pattern"
],
}),
],
entryPoints: await glob("../esbuild-plugin-react18-example/src/**/*.*"),
entryPoints: await glob("../packages/esbuild-plugin-react18-example/src/**/*.*"),
publicPath: "https://my.domain/static/",
external: ["react", "react-dom"],
outdir: "./test-build/" + outDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe.concurrent("Test plugin with default options in example build with tsup
const exampleBuildDir = path.resolve(
process.cwd(),
"..",
"packages",
"esbuild-plugin-react18-example",
"dist",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe.concurrent("Test plugin with ignorePatterns -- without content pattern"
bundle: true,
minify: true,
plugins: [react18Plugin({ ignorePatterns: [{ pathPattern: /star-me/ }] })],
entryPoints: await glob("../esbuild-plugin-react18-example/src/**/*.*"),
entryPoints: await glob("../packages/esbuild-plugin-react18-example/src/**/*.*"),
publicPath: "https://my.domain/static/",
external: ["react", "react-dom"],
outdir: "./test-build/" + outDir,
Expand Down Expand Up @@ -56,7 +56,7 @@ describe.concurrent("Test plugin with ignorePatterns with content pattern", asyn
ignorePatterns: [{ pathPattern: /star-me/, contentPatterns: [/ignore-me/] }],
}),
],
entryPoints: await glob("../esbuild-plugin-react18-example/src/**/*.*"),
entryPoints: await glob("../packages/esbuild-plugin-react18-example/src/**/*.*"),
publicPath: "https://my.domain/static/",
external: ["react", "react-dom"],
outdir: "./test-build/" + outDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe.concurrent("Test plugin with ignorePatterns -- without content pattern"
],
}),
],
entryPoints: await glob("../esbuild-plugin-react18-example/src/**/*.*"),
entryPoints: await glob("../packages/esbuild-plugin-react18-example/src/**/*.*"),
publicPath: "https://my.domain/static/",
external: ["react", "react-dom"],
outdir: "./test-build/" + outDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "esbuild-plugin-react18",
"author": "Mayank Kumar Chaudhari <https://mayank-chaudhari.vercel.app>",
"private": false,
"version": "0.0.7",
"version": "0.1.0",
"description": "Unleash the Power of React Server Components! ESBuild plugin to build RSC (React18 Server Components) compatible libraries.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -12,13 +12,13 @@
"publish-package": "cd dist && npm publish --provenance --access public"
},
"devDependencies": {
"@types/node": "^20.8.3",
"@vitest/coverage-v8": "^0.34.6",
"esbuild": "^0.19.4",
"octokit": "^3.1.1",
"@types/node": "^20.11.27",
"@vitest/coverage-v8": "^1.3.1",
"esbuild": "^0.20.1",
"octokit": "^3.1.2",
"tiny-glob": "^0.2.9",
"typescript": "^5.2.2",
"vitest": "^0.34.6"
"typescript": "^5.4.2",
"vitest": "^1.3.1"
},
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ if (!ref.startsWith(`@${owner}`)) {
);
const readMePath = path.resolve(process.cwd(), "README.md");
let readMe = fs.readFileSync(readMePath, { encoding: "utf8" });
const tmp = "!--|--!";
readMe = readMe.replace(new RegExp(`$${owner}/${ref}`, "g"), tmp);
const tmp = "!---!";
readMe = readMe.replace(new RegExp(`${owner}/${ref}`, "g"), tmp);
readMe = readMe.replace(new RegExp(ref, "g"), packageJson.name);
readMe = readMe.replace(new RegExp(tmp, "g"), `$${owner}/${ref}`);
readMe = readMe.replace(new RegExp(tmp, "g"), `${owner}/${ref}`);
fs.writeFileSync(readMePath, readMe);
}
8 changes: 8 additions & 0 deletions esbuild-plugin-react18/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const uuid = () => (Date.now() * Math.random()).toString(36).slice(0, 8);

/** regExp */
export const testPathRegExp = /.*\.(test|spec|check)\.(j|t)s(x)?$/i;

export const name = "esbuild-plugin-react18-" + uuid();
export const ignoreNamespace = "mayank1513-ignore-" + uuid();
export const keepNamespace = "mayank1513-keep-" + uuid();
Loading

0 comments on commit 0f910cf

Please sign in to comment.