| 176 | } |
| 177 | |
| 178 | private async _nodeJSLoadScript(scriptSrc: string): Promise<DefineCall | undefined> { |
| 179 | try { |
| 180 | const fs = (await import(/* webpackIgnore: true */ /* @vite-ignore */ `${'fs'}`)).default; |
| 181 | const vm = (await import(/* webpackIgnore: true */ /* @vite-ignore */ `${'vm'}`)).default; |
| 182 | const module = (await import(/* webpackIgnore: true */ /* @vite-ignore */ `${'module'}`)).default; |
| 183 | |
| 184 | const filePath = URI.parse(scriptSrc).fsPath; |
| 185 | const content = fs.readFileSync(filePath).toString(); |
| 186 | const scriptSource = module.wrap(content.replace(/^#!.*/, '')); |
| 187 | const script = new vm.Script(scriptSource); |
| 188 | const compileWrapper = script.runInThisContext(); |
| 189 | compileWrapper.apply(); |
| 190 | return this._defineCalls.pop(); |
| 191 | } catch (error) { |
| 192 | throw error; |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | const cache = new Map<string, Promise<any>>(); |