mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
jQuery no longer uses an alias in build-config.shared.js because Vite's code splitting caused TDZ errors when jquery was aliased. It now resolves directly from node_modules. The jquery.custom.js wrapper is removed since it interfered with Rollup's chunking. Instead, libs.js sets up window.$ and window.jQuery directly after importing jquery, then uses a fire-and-forget dynamic import for jquery-migrate to ensure proper load order. bundleEntries and config exports are moved from libs.js to the app entry points (analysis/index.ts and generic.js) to avoid circular dependency issues during Vite code splitting.
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
/**
|
|
* Build configuration for Vite
|
|
* Single source of truth for legacy module resolution
|
|
*/
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const scriptsBase = path.join(__dirname, "src");
|
|
const libsBase = path.join(scriptsBase, "libs");
|
|
const styleBase = path.join(scriptsBase, "style");
|
|
|
|
// Legacy exact-match aliases
|
|
export const legacyAliases = {
|
|
// Core libraries
|
|
// Note: jquery is NOT aliased - it resolves to node_modules/jquery directly
|
|
// The global setup (window.$, window.jQuery) is done in libs.js
|
|
jqueryVendor: path.join(libsBase, "jquery/jquery.js"),
|
|
storemodern: path.join(__dirname, "node_modules/store/dist/store.modern.js"),
|
|
|
|
// Vue
|
|
vue: path.join(__dirname, "node_modules/vue/dist/vue.esm.js"),
|
|
|
|
// Build config
|
|
config: path.join(scriptsBase, "config", process.env.NODE_ENV || "development") + ".js",
|
|
app: path.join(scriptsBase, "app.js"),
|
|
};
|
|
|
|
// Module resolution paths
|
|
export const modulePaths = [scriptsBase, "node_modules", styleBase];
|
|
|
|
// File extensions for resolution
|
|
export const extensions = [".ts", ".js", ".json", ".vue", ".scss"];
|
|
|
|
/**
|
|
* Get Vite-format aliases (uses regex patterns for exact matches)
|
|
*/
|
|
export function getViteAliases() {
|
|
const viteAliases = [
|
|
// @ alias
|
|
{ find: "@", replacement: scriptsBase },
|
|
];
|
|
|
|
// Add exact match patterns
|
|
for (const [key, value] of Object.entries(legacyAliases)) {
|
|
viteAliases.push({
|
|
find: new RegExp(`^${key}$`),
|
|
replacement: path.isAbsolute(value) ? value : path.join(__dirname, value),
|
|
});
|
|
}
|
|
|
|
// Add prefix patterns for legacy paths
|
|
viteAliases.push(
|
|
{ find: /^libs\//, replacement: libsBase + "/" },
|
|
{ find: /^ui\//, replacement: path.join(scriptsBase, "ui") + "/" },
|
|
);
|
|
|
|
return viteAliases;
|
|
}
|