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) {
17
17
await processFiles ( fullPath ) ;
18
18
} else if ( entry . isFile ( ) && entry . name . endsWith ( ".js" ) ) {
19
19
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" ) ;
21
29
const { dir, name } = parse ( fullPath ) ;
22
30
const newFullPath = join ( dir , `${ name } .mjs` ) ;
23
31
Original file line number Diff line number Diff line change @@ -65,13 +65,13 @@ export class SlsFramework implements IFramework {
65
65
resolveConfigurationPath = (
66
66
await import (
67
67
//@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"
69
69
)
70
70
) . default ;
71
71
readConfiguration = (
72
72
await import (
73
73
//@ts -ignore
74
- "serverless/lib/configuration/read." + " js" // hack for avoiding renaming to .mjs by build script
74
+ "serverless/lib/configuration/read.js"
75
75
)
76
76
) . default ;
77
77
Original file line number Diff line number Diff line change @@ -71,8 +71,8 @@ async function getBuild(functionId: string) {
71
71
Logger . verbose ( `[Function ${ functionId } ] Build complete` ) ;
72
72
}
73
73
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" )
76
76
) ;
77
77
78
78
if ( ! artifactFile ) {
You can’t perform that action at this time.
0 commit comments