File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @sveltejs/adapter-node ' : patch
3+ ---
4+
5+ [ fix] Correctly treat ` middlewares.js ` as external when using ` entryPoint ` option
Original file line number Diff line number Diff line change 77 statSync ,
88 writeFileSync
99} from 'fs' ;
10- import { join } from 'path' ;
10+ import { join , resolve } from 'path' ;
1111import { pipeline } from 'stream' ;
1212import glob from 'tiny-glob' ;
1313import { fileURLToPath } from 'url' ;
@@ -81,7 +81,6 @@ export default function ({
8181 entryPoints : [ entryPoint ] ,
8282 outfile : join ( out , 'index.js' ) ,
8383 bundle : true ,
84- external : [ './middlewares.js' ] , // does not work, eslint does not exclude middlewares from target
8584 format : 'esm' ,
8685 platform : 'node' ,
8786 target : 'node12' ,
@@ -90,8 +89,12 @@ export default function ({
9089 {
9190 name : 'fix-middlewares-exclude' ,
9291 setup ( build ) {
93- // Match an import called "./middlewares.js" and mark it as external
94- build . onResolve ( { filter : / ^ \. \/ m i d d l e w a r e s \. j s $ / } , ( ) => ( { external : true } ) ) ;
92+ // Match an import of "middlewares.js" and mark it as external
93+ build . onResolve ( { filter : / \/ m i d d l e w a r e s \. j s $ / } , ( { path, resolveDir } ) => {
94+ if ( resolve ( resolveDir , path ) === resolve ( out , 'middlewares.js' ) ) {
95+ return { path : './middlewares.js' , external : true } ;
96+ }
97+ } ) ;
9598 }
9699 }
97100 ]
You can’t perform that action at this time.
0 commit comments