Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedup non-exclusive external dependencies #396

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions rollup/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,9 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {
},
'./vscode/*': {
default: './vscode/src/*.js'
},
'./external/*': {
default: './external/*'
}
},
typesVersions: {
Expand Down Expand Up @@ -883,9 +886,16 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {

const isVscodeFile = resolved.startsWith(VSCODE_SRC_DIST_DIR)
const isServiceOverride = path.dirname(resolved) === DIST_SERVICE_OVERRIDE_DIR_MAIN
const isNotExclusive = (isVscodeFile || isServiceOverride) && !exclusiveModules.has(resolvedWithExtension)
const isExclusive = exclusiveModules.has(resolvedWithExtension)
const pathFromRoot = path.relative(DIST_DIR_MAIN, resolvedWithExtension)
const shouldBeShared = SHARED_ROOT_FILES_BETWEEN_PACKAGES.includes(path.relative(DIST_DIR_MAIN, resolvedWithExtension))
if (isNotExclusive || shouldBeShared) {
if (pathFromRoot.startsWith('external/') && !isExclusive) {
return {
external: true,
id: `vscode/${pathFromRoot}`
}
}
if (((isVscodeFile || isServiceOverride) && !isExclusive) || shouldBeShared) {
// Those modules will be imported from external monaco-vscode-api
let externalResolved = resolved.startsWith(VSCODE_SRC_DIST_DIR) ? `vscode/vscode/${path.relative(VSCODE_SRC_DIST_DIR, resolved)}` : `vscode/${path.relative(DIST_DIR_MAIN, resolved)}`
if (externalResolved.endsWith('.js')) {
Expand Down Expand Up @@ -1032,10 +1042,17 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {

const isVscodeFile = resolved.startsWith(VSCODE_SRC_DIST_DIR)
const isServiceOverride = path.dirname(resolved) === DIST_SERVICE_OVERRIDE_DIR_MAIN
const isNotExclusive = (isVscodeFile || isServiceOverride) && !exclusiveModules.has(resolvedWithExtension)
const isExclusive = exclusiveModules.has(resolvedWithExtension)
const pathFromRoot = path.relative(DIST_DIR_MAIN, resolvedWithExtension)
const shouldBeShared = SHARED_ROOT_FILES_BETWEEN_PACKAGES.includes(path.relative(DIST_DIR_MAIN, resolvedWithExtension))
if (pathFromRoot.startsWith('external/') && !isExclusive) {
return {
external: true,
id: `vscode/${pathFromRoot}`
}
}

if (isNotExclusive || shouldBeShared) {
if (((isVscodeFile || isServiceOverride) && !isExclusive) || shouldBeShared) {
// Those modules will be imported from external monaco-vscode-api
let externalResolved = resolved.startsWith(VSCODE_SRC_DIST_DIR) ? `vscode/vscode/${path.relative(VSCODE_SRC_DIST_DIR, resolved)}` : `vscode/${path.relative(DIST_DIR_MAIN, resolved)}`
if (externalResolved.endsWith('.js')) {
Expand Down