123456789101112131415161718192021222324252627 |
- import { normalizeModuleInfo } from "./module-info.js";
- import { createContents } from "./on-load.js";
- const PLUGIN_NAME = "global-externals";
- export const globalExternalsWithRegExp = (globals) => {
- const { modulePathFilter, getModuleInfo } = globals;
- return {
- name: PLUGIN_NAME,
- setup(build) {
- build.onResolve({ filter: modulePathFilter }, (args) => ({
- path: args.path,
- namespace: PLUGIN_NAME,
- }));
- build.onLoad({ filter: /.*/, namespace: PLUGIN_NAME }, (args) => {
-
- const modulePath = args.path;
- const moduleInfo = normalizeModuleInfo(getModuleInfo(modulePath));
- return { contents: createContents(moduleInfo) };
- });
- },
- };
- };
|