mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-24 04:36:33 +08:00
This is already used for more than just themes, and we plan to extend its usage even further
23 lines
571 B
JavaScript
Vendored
23 lines
571 B
JavaScript
Vendored
import rollupVirtualImports from "../rollup-virtual-imports";
|
|
|
|
export default function discourseVirtualLoader({ themeBase, modules, opts }) {
|
|
return {
|
|
name: "discourse-virtual-loader",
|
|
resolveId(source) {
|
|
if (rollupVirtualImports[source]) {
|
|
return `${themeBase}${source}`;
|
|
}
|
|
},
|
|
load(id) {
|
|
if (!id.startsWith(themeBase)) {
|
|
return;
|
|
}
|
|
|
|
const fromBase = id.slice(themeBase.length);
|
|
|
|
if (rollupVirtualImports[fromBase]) {
|
|
return rollupVirtualImports[fromBase](modules, opts);
|
|
}
|
|
},
|
|
};
|
|
}
|