File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,15 @@ async function processFiles(directory) {
1717 await processFiles ( fullPath ) ;
1818 } else if ( entry . isFile ( ) && entry . name . endsWith ( ".js" ) ) {
1919 const data = await readFile ( fullPath , "utf8" ) ;
20- const updatedData = data . replace ( / \. j s " / g, '.mjs"' ) ;
20+ const updatedData = data
21+ . split ( "\n" )
22+ . map ( ( line ) => {
23+ if ( line . trim ( ) . startsWith ( "import" ) ) {
24+ return line . replace ( / \. j s " / g, '.mjs"' ) ;
25+ }
26+ return line ;
27+ } )
28+ . join ( "\n" ) ;
2129 const { dir, name } = parse ( fullPath ) ;
2230 const newFullPath = join ( dir , `${ name } .mjs` ) ;
2331
Original file line number Diff line number Diff line change @@ -65,13 +65,13 @@ export class SlsFramework implements IFramework {
6565 resolveConfigurationPath = (
6666 await import (
6767 //@ts -ignore
68- "serverless/lib/cli/resolve-configuration-path." + " js" // hack for avoiding renaming to .mjs by build script
68+ "serverless/lib/cli/resolve-configuration-path.js"
6969 )
7070 ) . default ;
7171 readConfiguration = (
7272 await import (
7373 //@ts -ignore
74- "serverless/lib/configuration/read." + " js" // hack for avoiding renaming to .mjs by build script
74+ "serverless/lib/configuration/read.js"
7575 )
7676 ) . default ;
7777
Original file line number Diff line number Diff line change @@ -71,8 +71,8 @@ async function getBuild(functionId: string) {
7171 Logger . verbose ( `[Function ${ functionId } ] Build complete` ) ;
7272 }
7373
74- const artifactFile = Object . keys ( result . metafile ?. outputs ! ) . find (
75- ( key ) => key . endsWith ( "." + " js") // hack for avoiding renaming to .mjs by build script
74+ const artifactFile = Object . keys ( result . metafile ?. outputs ! ) . find ( ( key ) =>
75+ key . endsWith ( ".js" )
7676 ) ;
7777
7878 if ( ! artifactFile ) {
You can’t perform that action at this time.
0 commit comments