File tree Expand file tree Collapse file tree 4 files changed +24
-6
lines changed
Expand file tree Collapse file tree 4 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 1+ const plugin = ( ) => {
2+ return {
3+ name : 'mark-as-commonjs' ,
4+ resolveImportMeta : ( property ) => {
5+ if ( property == 'isBundlingToCommonJs' ) {
6+ return 'true' ;
7+ }
8+
9+ return null ;
10+ } ,
11+ } ;
12+ } ;
13+
114export default [
215 {
316 input : 'lib/index.js' ,
17+ plugins : [ plugin ( ) ] ,
418 output : {
519 file : 'dist/bundle.cjs' ,
6- format : 'cjs'
20+ format : 'cjs' ,
21+ sourcemap : true
722 }
823 } ,
924 {
1025 input : 'lib/db/SqliteWorker.js' ,
26+ plugins : [ plugin ( ) ] ,
1127 output : {
1228 file : 'dist/worker.cjs' ,
13- format : 'cjs'
29+ format : 'cjs' ,
30+ sourcemap : true
1431 }
1532 }
1633] ;
Original file line number Diff line number Diff line change @@ -57,8 +57,7 @@ export class BetterSQLite3DBAdapter extends BaseObserver<DBAdapterListener> impl
5757 }
5858
5959 const openWorker = async ( isWriter : boolean ) => {
60- // https://nodejs.org/api/esm.html#differences-between-es-modules-and-commonjs
61- const isCommonJsModule = '__filename' in global ;
60+ const isCommonJsModule = import . meta. isBundlingToCommonJs ?? false ;
6261 let worker : Worker ;
6362 const workerName = isWriter ? `write ${ dbFilePath } ` : `read ${ dbFilePath } ` ;
6463
Original file line number Diff line number Diff line change @@ -98,8 +98,7 @@ class BetterSqliteWorker implements AsyncDatabaseOpener {
9898}
9999
100100const loadExtension = ( db : Database ) => {
101- // https://nodejs.org/api/esm.html#differences-between-es-modules-and-commonjs
102- const isCommonJsModule = '__filename' in global ;
101+ const isCommonJsModule = import . meta. isBundlingToCommonJs ?? false ;
103102
104103 const platform = OS . platform ( ) ;
105104 let extensionPath : string ;
Original file line number Diff line number Diff line change 1+ interface ImportMeta {
2+ isBundlingToCommonJs ?: boolean // This property is set by our rollup configuration
3+ }
You can’t perform that action at this time.
0 commit comments