@@ -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`
2514const 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 : / ( \/ s e r v e r \/ ) | ( \. s e r v e r \. ( j s | t s ) 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.
0 commit comments