Skip to content

Commit 3222de6

Browse files
committed
fix error on esbuild bundle
Signed-off-by: shmck <[email protected]>
1 parent 3556ede commit 3222de6

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Diff for: .vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"coderoad",
1919
"esbuild",
2020
"flowtype",
21+
"fsevents",
2122
"outfile",
2223
"packagejson",
2324
"prismjs",

Diff for: src/services/node/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { WORKSPACE_ROOT } from '../../environment'
66

77
const asyncExec = promisify(cpExec)
88
const asyncRemoveFile = promisify(fs.unlink)
9-
const asyncReadFile = promisify(fs.readFile)
9+
export const asyncReadFile = promisify(fs.readFile)
1010
const asyncWriteFile = promisify(fs.writeFile)
1111

1212
interface ExecParams {

Diff for: src/services/webview/render.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { JSDOM } from 'jsdom'
22
import * as path from 'path'
33
import * as vscode from 'vscode'
4+
import { asyncReadFile } from '../node'
45
import { onError } from '../telemetry'
56
import { CONTENT_SECURITY_POLICY_EXEMPTIONS } from '../../environment'
67

@@ -64,7 +65,18 @@ async function render(panel: vscode.WebviewPanel, rootPath: string): Promise<voi
6465
const runTimeScript = document.createElement('script')
6566
runTimeScript.nonce = getNonce()
6667
nonces.push(runTimeScript.nonce)
67-
const manifest = await import(path.join(rootPath, 'asset-manifest.json'))
68+
69+
// note: file cannot be imported or results in esbuild error. Easier to read it.
70+
let manifest
71+
try {
72+
const manifestPath = path.join(rootPath, 'asset-manifest.json')
73+
console.log(manifestPath)
74+
const manifestFile = await asyncReadFile(manifestPath, 'utf8')
75+
manifest = JSON.parse(manifestFile)
76+
} catch (e) {
77+
throw new Error('Failed to read manifest file')
78+
}
79+
6880
runTimeScript.src = createUri(manifest.files['runtime-main.js'])
6981
document.body.appendChild(runTimeScript)
7082

0 commit comments

Comments
 (0)