@@ -138,18 +138,9 @@ module.exports = class Inliner {
138
138
allowOverwrite : true ,
139
139
entryPoints : [ path . join ( root , this . subfolder , this . package , "src" , "index.ts" ) ] ,
140
140
outfile : this . outfile ,
141
- external : [
142
- "tslib" ,
143
- "@aws-crypto/*" ,
144
- "@smithy/*" ,
145
- "@aws-sdk/*" ,
146
- "typescript" ,
147
- "vscode-oniguruma" ,
148
- "pnpapi" ,
149
- "fast-xml-parser" ,
150
- "node_modules/*" ,
151
- ...this . variantExternalsForEsBuild ,
152
- ] ,
141
+ keepNames : true ,
142
+ packages : "external" ,
143
+ external : [ ...this . variantExternalsForEsBuild ] ,
153
144
} ) ;
154
145
return this ;
155
146
}
@@ -161,6 +152,12 @@ module.exports = class Inliner {
161
152
async rewriteStubs ( ) {
162
153
for await ( const file of walk ( path . join ( this . packageDirectory , "dist-cjs" ) ) ) {
163
154
const relativePath = file . replace ( path . join ( this . packageDirectory , "dist-cjs" ) , "" ) . slice ( 1 ) ;
155
+
156
+ if ( ! file . endsWith ( ".js" ) ) {
157
+ console . log ( "Skipping" , path . basename ( file ) , "file extension is not .js." ) ;
158
+ continue ;
159
+ }
160
+
164
161
if ( relativePath === "index.js" ) {
165
162
console . log ( "Skipping index.js" ) ;
166
163
continue ;
@@ -198,12 +195,12 @@ module.exports = class Inliner {
198
195
const basename = path . basename ( variant ) . replace ( / .j s $ / , "" ) ;
199
196
const dirname = path . dirname ( variant ) ;
200
197
201
- const find = new RegExp ( `require\\("./ (.*?)/${ basename } "\\)` ) ;
198
+ const find = new RegExp ( `require\\("\\. (.*?)/${ basename } "\\)` ) ;
202
199
const replace = `require("./${ dirname } /${ basename } ")` ;
203
200
204
201
this . indexContents = this . indexContents . replace ( find , replace ) ;
205
202
206
- console . log ( "replacing " , find , "with" , replace ) ;
203
+ console . log ( "Replacing " , find , "with" , replace ) ;
207
204
}
208
205
209
206
fs . writeFileSync ( this . outfile , this . indexContents , "utf-8" ) ;
@@ -235,7 +232,7 @@ module.exports = class Inliner {
235
232
const redundantVariable = `import_${ variableSuffix } ${ redundancyIndex } ` ;
236
233
237
234
if ( this . indexContents . match ( new RegExp ( redundantRequire ) ) ) {
238
- console . log ( "replacing " , redundantVariable ) ;
235
+ console . log ( "Replacing var " , redundantVariable ) ;
239
236
this . indexContents = this . indexContents
240
237
. replace ( new RegExp ( redundantRequire , "g" ) , "" )
241
238
. replace ( new RegExp ( redundantVariable , "g" ) , `import_${ variableSuffix } ` ) ;
0 commit comments