Skip to content

Commit 82dc8cd

Browse files
committed
Add "use client" directive after bundling
1 parent 650eb64 commit 82dc8cd

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"sideEffects": false,
1919
"scripts": {
2020
"clear": "npm run clear:parcel-cache & npm run clear:builds & npm run clear:node_modules",
21-
"clear:builds": "rm -rf ./packages/*/dist",
21+
"clear:builds": "rm -rf ./dist",
2222
"clear:parcel-cache": "rm -rf ./.parcel-cache",
2323
"clear:node_modules": "rm -rf ./node_modules",
24-
"prerelease": "rm -rf ./.parcel-cache && parcel build",
24+
"prerelease": "rm -rf ./.parcel-cache && parcel build && ./postprocess.js",
2525
"prettier": "prettier --write \"**/*.{css,html,js,json,jsx,ts,tsx}\"",
2626
"prettier:ci": "prettier --check \"**/*.{css,html,js,json,jsx,ts,tsx}\"",
2727
"test": "jest",

postprocess.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env node
2+
3+
const { readFileSync, writeFileSync } = require("fs");
4+
const { join } = require("path");
5+
6+
const packageString = readFileSync(join(__dirname, "package.json"), "utf8");
7+
const packageJSON = JSON.parse(packageString);
8+
9+
[packageJSON.main, packageJSON.module].forEach((distPath) => {
10+
const path = join(__dirname, distPath);
11+
const bundleText = readFileSync(path, "utf8");
12+
writeFileSync(path, `"use client";\n\n${bundleText}`);
13+
});

src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use client";
2-
31
export * from "./ErrorBoundary";
42
export * from "./ErrorBoundaryContext";
53
export * from "./useErrorBoundary";

0 commit comments

Comments
 (0)