@@ -24,77 +24,42 @@ const renameImportPlugin = {
2424 } ,
2525} ;
2626
27- const nativeNodeModulesPlugin = {
28- name : 'native-node-modules' ,
29- setup ( build ) {
30- // If a ".node" file is imported within a module in the "file" namespace, resolve
31- // it to an absolute path and put it into the "node-file" virtual namespace.
32- build . onResolve ( { filter : / \. n o d e $ / , namespace : 'file' } , args => ( {
33- path : require . resolve ( args . path , { paths : [ args . resolveDir ] } ) ,
34- namespace : 'node-file' ,
35- } ) )
36-
37- // Files in the "node-file" virtual namespace call "require()" on the
38- // path from esbuild of the ".node" file in the output directory.
39- build . onLoad ( { filter : / .* / , namespace : 'node-file' } , args => ( {
40- contents : `
41- import path from ${ JSON . stringify ( args . path ) }
42- try { module.exports = require(path) }
43- catch {}
44- ` ,
45- } ) )
46-
47- // If a ".node" file is imported within a module in the "node-file" namespace, put
48- // it in the "file" namespace where esbuild's default loading behavior will handle
49- // it. It is already an absolute path since we resolved it to one above.
50- build . onResolve ( { filter : / \. n o d e $ / , namespace : 'node-file' } , args => ( {
51- path : args . path ,
52- namespace : 'file' ,
53- } ) )
54-
55- // Tell esbuild's default loading behavior to use the "file" loader for
56- // these ".node" files.
57- let opts = build . initialOptions
58- opts . loader = opts . loader || { }
59- opts . loader [ '.node' ] = 'file'
60- } ,
61- }
62-
63-
6427esbuild . build ( {
6528 banner : {
6629 js : banner ,
6730 } ,
6831 loader : { ".node" : "file" } ,
69- bundle : true ,
70- entryPoints : [ 'src/plugin/main.ts' ] ,
71- external : [
72- 'obsidian' ,
73- 'electron' ,
74- 'codemirror' ,
75- '@codemirror/autocomplete' ,
76- '@codemirror/closebrackets' ,
77- '@codemirror/commands' ,
78- '@codemirror/fold' ,
79- '@codemirror/gutter' ,
80- '@codemirror/history' ,
81- '@codemirror/language' ,
82- '@codemirror/rangeset' ,
83- '@codemirror/rectangular-selection' ,
84- '@codemirror/search' ,
85- '@codemirror/state' ,
86- '@codemirror/stream-parser' ,
87- '@codemirror/text' ,
88- '@codemirror/view' ,
89- ...builtins ,
90- ] ,
91- format : 'cjs' ,
92- logLevel : 'info' ,
93- minify : prod ,
94- outfile : 'main.js' ,
95- sourcemap : prod ? false : 'inline' ,
96- target : 'es2016' ,
97- treeShaking : true ,
32+ bundle : true ,
33+ entryPoints : [ 'src/plugin/main.ts' ] ,
34+ external : [
35+ 'obsidian' ,
36+ 'electron' ,
37+ 'codemirror' ,
38+ '@codemirror/autocomplete' ,
39+ '@codemirror/closebrackets' ,
40+ '@codemirror/commands' ,
41+ '@codemirror/fold' ,
42+ '@codemirror/gutter' ,
43+ '@codemirror/history' ,
44+ '@codemirror/language' ,
45+ '@codemirror/rangeset' ,
46+ '@codemirror/rectangular-selection' ,
47+ '@codemirror/search' ,
48+ '@codemirror/state' ,
49+ '@codemirror/stream-parser' ,
50+ '@codemirror/text' ,
51+ '@codemirror/view' ,
52+ ...builtins ,
53+ ] ,
54+ format : 'cjs' ,
55+ logLevel : 'info' ,
56+ minify : prod ,
57+ minifySyntax : prod ,
58+ minifyWhitespace : prod ,
59+ minifyIdentifiers : prod ,
60+ outfile : 'main.js' ,
61+ sourcemap : prod ? false : "inline" ,
62+ target : 'es2016' ,
63+ treeShaking : true ,
9864 plugins : [ renameImportPlugin ]
99- } )
100- . catch ( ( ) => process . exit ( 1 ) ) ;
65+ } ) . catch ( ( ) => process . exit ( 1 ) ) ;
0 commit comments