File tree Expand file tree Collapse file tree 4 files changed +45
-3
lines changed Expand file tree Collapse file tree 4 files changed +45
-3
lines changed Original file line number Diff line number Diff line change 1+ const { pathToFileURL } = require ( 'url' ) ;
2+
3+ const RSCWebpackLoader = async function Loader ( source , sourceMap ) {
4+ // Mark loader as async since we're doing async operations
5+ const callback = this . async ( ) ;
6+
7+ try {
8+ // Convert file path to URL format
9+ const fileUrl = pathToFileURL ( this . resourcePath ) . href ;
10+
11+ const { load } = await import ( 'react-server-dom-webpack/node-loader' ) ;
12+ const result = await load ( fileUrl , null , async ( ) => ( {
13+ format : 'module' ,
14+ source,
15+ } ) ) ;
16+
17+ callback ( null , result . source , sourceMap ) ;
18+ } catch ( error ) {
19+ callback ( error ) ;
20+ }
21+ } ;
22+
23+ module . exports = RSCWebpackLoader ;
Original file line number Diff line number Diff line change 1+ declare module 'react-server-dom-webpack/node-loader' {
2+ interface LoadOptions {
3+ format : 'module' ;
4+ source : string ;
5+ }
6+
7+ interface LoadResult {
8+ source : string ;
9+ }
10+
11+ // eslint-disable-next-line import/prefer-default-export
12+ export function load (
13+ url : string ,
14+ context : null | object ,
15+ defaultLoad : ( ) => Promise < LoadOptions >
16+ ) : Promise < LoadResult > ;
17+ }
Original file line number Diff line number Diff line change 77 "node" : " ./node_package/lib/ReactOnRails.node.js" ,
88 "rsc-server" : " ./node_package/lib/ReactOnRailsRSC.js" ,
99 "default" : " ./node_package/lib/ReactOnRails.js"
10- }
10+ },
11+ "./RSCWebpackLoader" : " ./node_package/lib/RSCWebpackLoader.js"
1112 },
1213 "directories" : {
1314 "doc" : " docs"
6061 "prepack" : " nps build.prepack" ,
6162 "prepare" : " nps build.prepack" ,
6263 "prepublishOnly" : " yarn run build" ,
63- "build" : " yarn run clean && yarn run tsc --declaration" ,
64+ "build" : " yarn run clean && yarn run tsc --declaration && cp node_package/src/RSCWebpackLoader.js node_package/lib " ,
6465 "build-watch" : " yarn run clean && yarn run tsc --watch" ,
6566 "lint" : " nps eslint" ,
6667 "check" : " yarn run lint && yarn run test && yarn run type-check" ,
Original file line number Diff line number Diff line change 1111 "incremental" : true ,
1212 "target" : " es5"
1313 },
14- "include" : [" node_package/src/**/*" ]
14+ "include" : [" node_package/src/**/*" ],
15+ "exclude" : [" node_package/src/RSCWebpackLoader.js" ]
1516}
You can’t perform that action at this time.
0 commit comments