Skip to content

Commit 3a6f9ea

Browse files
fix: Decouple pitcher-client (#148)
1 parent a2f7de0 commit 3a6f9ea

33 files changed

Lines changed: 408 additions & 1413 deletions

build/plugins.cjs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,3 @@ module.exports.moduleReplacementPlugin = function moduleReplacementPlugin(
1212
},
1313
};
1414
};
15-
16-
module.exports.forbidImportsPlugin = function forbidImportsPlugin(imports) {
17-
return {
18-
name: "forbid-imports",
19-
setup(build) {
20-
for (const packageName of imports) {
21-
// catch `import ... from 'packageName'` **and** sub-paths `packageName/foo`
22-
const pkgFilter = new RegExp(`^${packageName}($|/)`);
23-
build.onResolve({ filter: pkgFilter }, (args) => {
24-
return {
25-
errors: [
26-
{
27-
text: `❌ Importing “${packageName}” is forbidden in this project.`,
28-
notes: [
29-
"If you really need it, talk to your team lead about an exception.",
30-
],
31-
},
32-
],
33-
};
34-
});
35-
}
36-
},
37-
};
38-
};

esbuild.cjs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
const { join } = require("path");
22
const esbuild = require("esbuild");
33
const { externalModules, define } = require("./build/utils.cjs");
4-
const {
5-
moduleReplacementPlugin,
6-
forbidImportsPlugin,
7-
} = require("./build/plugins.cjs");
8-
9-
// Until pitcher-client is part of SDK we need to forbid these imports in
10-
// Node builds
11-
const preventPitcherClientImportsPlugin = forbidImportsPlugin([
12-
"@codesandbox/pitcher-protocol",
13-
"@codesandbox/pitcher-common",
14-
]);
4+
const { moduleReplacementPlugin } = require("./build/plugins.cjs");
155

166
const devtoolsStubPlugin = {
177
name: "stub-react-devtools",
@@ -86,7 +76,6 @@ const nodeClientCjsBuild = esbuild.build({
8676
outfile: "dist/cjs/node.cjs",
8777
platform: "node",
8878
external: externalModules,
89-
plugins: [preventPitcherClientImportsPlugin],
9079
});
9180

9281
const nodeClientEsmBuild = esbuild.build({
@@ -96,7 +85,6 @@ const nodeClientEsmBuild = esbuild.build({
9685
outfile: "dist/esm/node.js",
9786
platform: "node",
9887
external: externalModules,
99-
plugins: [preventPitcherClientImportsPlugin],
10088
});
10189

10290
/**
@@ -121,7 +109,6 @@ const sdkEsmBuild = esbuild.build({
121109
platform: "node",
122110
outfile: "dist/esm/index.js",
123111
external: externalModules,
124-
plugins: [preventPitcherClientImportsPlugin],
125112
});
126113

127114
/**
@@ -147,7 +134,7 @@ const cliBuild = esbuild.build({
147134
),
148135
"@codesandbox/sdk",
149136
],
150-
plugins: [preventPitcherClientImportsPlugin, devtoolsStubPlugin],
137+
plugins: [devtoolsStubPlugin],
151138
});
152139

153140
Promise.all([

0 commit comments

Comments
 (0)