Skip to content

Commit 204274b

Browse files
Redditbaraben-harris-5
authored andcommitted
Project import generated by Copybara.
GitOrigin-RevId: 710a5d8064274048f54f0c76deb5666d64ffe255
1 parent 01f929e commit 204274b

3 files changed

Lines changed: 0 additions & 68 deletions

File tree

packages/build-pack/src/__tests__/esbuild/ESBuildPack.spec.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -534,30 +534,6 @@ describe('ES Build Pack', () => {
534534
expect(cleanedUpCode).not.toContain(`__toESM(require_${stub}(), 1)`)
535535
);
536536
});
537-
538-
it('removes plugin code when DEVVIT_BUNDLE_STRIP_PLUGINS is set', async () => {
539-
process.env.DEVVIT_BUNDLE_STRIP_PLUGINS = '1';
540-
const result = await build({
541-
bundle: true,
542-
entryPoints: [path.resolve(__dirname, '..', 'test-actors', 'code-split', 'main.tsx')],
543-
minify: false,
544-
outfile: 'main.js',
545-
plugins: [serverClientCodeSplit(true)],
546-
format: 'cjs',
547-
jsxFactory: 'Devvit.createFragment',
548-
jsxFragment: 'Devvit.Fragment',
549-
target: 'es2020',
550-
write: false,
551-
});
552-
const clientBundle = result.outputFiles.find((bundle) =>
553-
bundle.text.includes('"server-only:')
554-
);
555-
expect(clientBundle?.text).not.toBeUndefined();
556-
const stubbedRedis = result.outputFiles?.[0]?.text.match(
557-
/var import_RedisClient[0-9]* = __toESM\(require_server_stub\(\), 1\)/gm
558-
);
559-
expect(stubbedRedis).toBeTruthy();
560-
});
561537
});
562538
});
563539

packages/build-pack/src/esbuild/plugins/serverClientCodeSplit.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@ import type {
1010
PluginBuild,
1111
} from 'esbuild';
1212

13-
// public-api paths to strip from client builds
14-
// subfolders of: packages/public-api/src/apis/
15-
const SERVER_ONLY_PLUGIN_PATHS = [
16-
'key-value-storage',
17-
'media',
18-
'modLog',
19-
'reddit',
20-
'redis',
21-
'scheduler',
22-
];
23-
2413
// Code stamped in client builds that replaces server-only code as `server-stub.js`
2514
const CLIENT_CIRCUITBREAK_STUB = `
2615
let circuitBreak = globalThis.circuitBreak;
@@ -65,18 +54,6 @@ export function serverClientCodeSplit(watchMode: boolean = false): Plugin {
6554
return {
6655
name: 'removeServerCode',
6756
setup(build: PluginBuild) {
68-
let publicApiDir: string;
69-
70-
// We can't call build.resolve() outside of one of the plugin callbacks
71-
build.onStart(async () => {
72-
const { path: resolvedPath } = await build.resolve('@devvit/public-api', {
73-
resolveDir: '.',
74-
kind: 'import-statement',
75-
pluginData: 'removeServerCodeStart',
76-
});
77-
publicApiDir = path.dirname(resolvedPath);
78-
});
79-
8057
// Remove code the developer has marked as server-only by naming convention:
8158
build.onResolve(
8259
{ filter: /(\/server\/)|(\.server\.(js|ts)x?$)/ },
@@ -113,26 +90,6 @@ export function serverClientCodeSplit(watchMode: boolean = false): Plugin {
11390
}
11491
);
11592

116-
// If set, don't strip plugin code from client bundles
117-
if (process.env.DEVVIT_BUNDLE_STRIP_PLUGINS === '1') {
118-
// Remove plugins from public-api that are non-op on clients and always
119-
// result in a circuit break:
120-
// eslint-disable-next-line security/detect-non-literal-regexp
121-
const publicApiFilter = new RegExp(`/(${SERVER_ONLY_PLUGIN_PATHS.join('|')})/`);
122-
build.onResolve({ filter: publicApiFilter }, (args: OnResolveArgs): OnResolveResult => {
123-
// Since the regex for public-api paths is so broad, ensure the resolved import is from
124-
// @devvit/public-api and not someplace else
125-
if (!args.importer.startsWith(publicApiDir)) {
126-
return {};
127-
}
128-
129-
return {
130-
namespace: SERVER_ONLY_NAMESPACE,
131-
path: SERVER_ONLY_FILENAME,
132-
};
133-
});
134-
}
135-
13693
// Create the circuit break stub and return a Proxy object so any
13794
// fields or functions imported throw a CircuitBreak exception instead
13895
// of a ReferenceError.

packages/public-api/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
},
3434
"types": "./dist/index.d.ts",
3535
"dependencies": {
36-
"@devvit/metrics": "0.13.7",
3736
"@devvit/protos": "0.13.7",
3837
"@devvit/shared": "0.13.7",
3938
"@devvit/shared-types": "0.13.7",

0 commit comments

Comments
 (0)