Skip to content

Commit

Permalink
Merge pull request #241 from CodinGame/improve-asset-management
Browse files Browse the repository at this point in the history
Improve asset management
  • Loading branch information
CGNonofr authored Nov 14, 2023
2 parents 7a2fe00 + 6cd7e29 commit aff4f2f
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 43 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Release

on:
push:
branches: [main]
on: workflow_dispatch

permissions:
contents: write # to be able to publish a GitHub release
Expand Down
5 changes: 1 addition & 4 deletions rollup/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,7 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {
return '[name].js'
},
chunkFileNames: '[name].js',
hoistTransitiveImports: false,
paths: {
'monaco-editor': 'monaco-editor/esm/vs/editor/editor.api.js'
}
hoistTransitiveImports: false
}],
input,
plugins: [
Expand Down
106 changes: 92 additions & 14 deletions scripts/vscode.patch

Large diffs are not rendered by default.

22 changes: 4 additions & 18 deletions src/assets.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
let assetUrls: Record<string, string | (() => string)> = {}
export function registerAssets (assets: Record<string, string | (() => string)>): void {
assetUrls = {
...assetUrls,
...assets
}
}
import { FileAccess } from 'vs/base/common/network'

function toUrl (name: string): string | undefined {
let url = assetUrls[name]
if (typeof url === 'function') {
url = url()
export function registerAssets (assets: Record<string, string | (() => string)>): void {
for (const [moduleId, url] of Object.entries(assets)) {
FileAccess.registerAppResourcePathUrl(moduleId, url)
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
return new URL(url ?? '', globalThis.location?.href ?? import.meta.url).toString()
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(globalThis as any).monacoRequire = {
toUrl
}
4 changes: 0 additions & 4 deletions src/server/bootstrap-fork.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createRequire } from 'node:module'
import { registerAssets } from '../assets'

const entrypoints: Record<string, () => Promise<void>> = {
'vs/workbench/api/node/extensionHostProcess': async () => { await import('vs/workbench/api/node/extensionHostProcess') },
Expand All @@ -10,9 +9,6 @@ const entrypoints: Record<string, () => Promise<void>> = {

const require = createRequire(import.meta.url)

// just to create globalThis.monacoRequire
registerAssets({})

// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(globalThis as any)._VSCODE_NODE_MODULES = new Proxy(Object.create(null), { get: (_target, mod) => require(String(mod)) })

Expand Down

0 comments on commit aff4f2f

Please sign in to comment.