Skip to content

Commit

Permalink
fix: preload assets
Browse files Browse the repository at this point in the history
  • Loading branch information
CompuIves committed Nov 16, 2023
1 parent 534906d commit bc7d9e0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions rollup/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const DIST_DIR_MAIN = path.resolve(DIST_DIR, 'main')
const VSCODE_SRC_DIST_DIR = path.resolve(DIST_DIR_MAIN, 'vscode', 'src')
const VSCODE_DIR = path.resolve(BASE_DIR, 'vscode')
const VSCODE_SRC_DIR = path.resolve(VSCODE_DIR, 'src')
const ASSETS_PATH = path.resolve(BASE_DIR, 'src/assets')
const NODE_MODULES_DIR = path.resolve(BASE_DIR, 'node_modules')
const MONACO_EDITOR_DIR = path.resolve(NODE_MODULES_DIR, './monaco-editor')
const MONACO_EDITOR_ESM_DIR = path.resolve(MONACO_EDITOR_DIR, './esm')
Expand Down Expand Up @@ -550,6 +551,26 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {
assetFileNames: 'assets/[name][extname]',
format: 'esm',
dir: 'dist/main',
intro (chunk) {
// Ensure that all our files start with an import to `assets.ts`, as this
// file has a side-effect (setting monacoRequire on globalThis) that needs
// to be evaluated before VSCode evaluates. Because VSCode needs this side-effect
// for its own side-effects.
if (chunk.facadeModuleId == null) {
return ''
}

if (!chunk.facadeModuleId.startsWith(SRC_DIR)) {
return ''
}

let relativePath = path.relative(path.dirname(chunk.facadeModuleId), ASSETS_PATH)
if (!relativePath.startsWith('.')) {
relativePath = './' + relativePath
}

return `import "${relativePath}";\n`
},
entryFileNames: (chunkInfo) => {
// Rename node_modules to external so it's not removing while publishing the package
// tslib and rollup-plugin-styles and bundled
Expand Down
4 changes: 2 additions & 2 deletions src/missing-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ import { ITitleService } from 'vs/workbench/services/title/common/titleService'
import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents'
import { IActiveLanguagePackService, ILocaleService } from 'vs/workbench/services/localization/common/locale'
import { joinPath } from 'vs/base/common/resources'
import { unsupported } from './tools'
import { getBuiltInExtensionTranslationsUris } from './l10n'
import { IExtensionIgnoredRecommendationsService, IExtensionRecommendationsService } from 'vs/workbench/services/extensionRecommendations/common/extensionRecommendations'
import { IIgnoredExtensionsManagementService } from 'vs/platform/userDataSync/common/ignoredExtensions'
import { IExtensionRecommendationNotificationService } from 'vs/platform/extensionRecommendations/common/extensionRecommendations'
import { IWorkspaceExtensionsConfigService } from 'vs/workbench/services/extensionRecommendations/common/workspaceExtensionsConfig'
import { IRemoteUserDataProfilesService } from 'vs/workbench/services/userDataProfile/common/remoteUserDataProfiles'
import { IExtensionBisectService } from 'vs/workbench/services/extensionManagement/browser/extensionBisect'
import { IUserDataSyncAccountService } from 'vs/platform/userDataSync/common/userDataSyncAccount'
import { unsupported } from './tools'
import { getBuiltInExtensionTranslationsUris } from './l10n'

class NullLoggerService extends AbstractLoggerService {
constructor () {
Expand Down

0 comments on commit bc7d9e0

Please sign in to comment.