@powerlines/plugin-rspack 0.5.231 → 0.5.232
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/rolldown_runtime.cjs +0 -2
- package/dist/helpers/unplugin.cjs +4 -3
- package/dist/helpers/unplugin.mjs +3 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/powerlines/package.cjs +11 -0
- package/dist/powerlines/package.mjs +5 -0
- package/dist/powerlines/schemas/fs.cjs +226 -0
- package/dist/powerlines/schemas/fs.mjs +224 -0
- package/dist/powerlines/src/api.cjs +568 -0
- package/dist/powerlines/src/api.mjs +566 -0
- package/dist/powerlines/src/internal/helpers/environment.cjs +50 -0
- package/dist/powerlines/src/internal/helpers/environment.mjs +47 -0
- package/dist/powerlines/src/internal/helpers/generate-types.cjs +78 -0
- package/dist/powerlines/src/internal/helpers/generate-types.mjs +76 -0
- package/dist/powerlines/src/internal/helpers/hooks.cjs +65 -0
- package/dist/powerlines/src/internal/helpers/hooks.mjs +63 -0
- package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +24 -0
- package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +23 -0
- package/dist/powerlines/src/internal/helpers/install.cjs +36 -0
- package/dist/powerlines/src/internal/helpers/install.mjs +35 -0
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +97 -0
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +93 -0
- package/dist/powerlines/src/internal/helpers/resolver.cjs +43 -0
- package/dist/powerlines/src/internal/helpers/resolver.mjs +41 -0
- package/dist/powerlines/src/lib/build/rspack.cjs +39 -0
- package/dist/powerlines/src/lib/build/rspack.mjs +37 -0
- package/dist/powerlines/src/lib/config-file.cjs +79 -0
- package/dist/powerlines/src/lib/config-file.mjs +76 -0
- package/dist/powerlines/src/lib/constants/environments.cjs +8 -0
- package/dist/powerlines/src/lib/constants/environments.mjs +6 -0
- package/dist/powerlines/src/lib/contexts/api-context.cjs +184 -0
- package/dist/powerlines/src/lib/contexts/api-context.mjs +182 -0
- package/dist/powerlines/src/lib/contexts/context.cjs +951 -0
- package/dist/powerlines/src/lib/contexts/context.mjs +949 -0
- package/dist/powerlines/src/lib/contexts/environment-context.cjs +195 -0
- package/dist/powerlines/src/lib/contexts/environment-context.mjs +194 -0
- package/dist/powerlines/src/lib/contexts/plugin-context.cjs +78 -0
- package/dist/powerlines/src/lib/contexts/plugin-context.mjs +77 -0
- package/dist/powerlines/src/lib/entry.cjs +85 -0
- package/dist/powerlines/src/lib/entry.mjs +83 -0
- package/dist/powerlines/src/lib/fs/helpers.cjs +85 -0
- package/dist/powerlines/src/lib/fs/helpers.mjs +81 -0
- package/dist/powerlines/src/lib/fs/storage/base.cjs +196 -0
- package/dist/powerlines/src/lib/fs/storage/base.mjs +195 -0
- package/dist/powerlines/src/lib/fs/storage/file-system.cjs +170 -0
- package/dist/powerlines/src/lib/fs/storage/file-system.mjs +169 -0
- package/dist/powerlines/src/lib/fs/storage/virtual.cjs +88 -0
- package/dist/powerlines/src/lib/fs/storage/virtual.mjs +87 -0
- package/dist/powerlines/src/lib/fs/vfs.cjs +912 -0
- package/dist/powerlines/src/lib/fs/vfs.mjs +910 -0
- package/dist/powerlines/src/lib/logger.cjs +58 -0
- package/dist/powerlines/src/lib/logger.mjs +55 -0
- package/dist/powerlines/src/lib/typescript/ts-morph.cjs +103 -0
- package/dist/powerlines/src/lib/typescript/ts-morph.mjs +101 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +149 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +144 -0
- package/dist/powerlines/src/lib/unplugin/factory.cjs +6 -0
- package/dist/powerlines/src/lib/unplugin/factory.mjs +8 -0
- package/dist/powerlines/src/lib/unplugin/helpers.cjs +29 -0
- package/dist/powerlines/src/lib/unplugin/helpers.mjs +27 -0
- package/dist/powerlines/src/lib/unplugin/index.cjs +4 -0
- package/dist/powerlines/src/lib/unplugin/index.mjs +6 -0
- package/dist/powerlines/src/lib/unplugin/module-resolution.cjs +66 -0
- package/dist/powerlines/src/lib/unplugin/module-resolution.mjs +65 -0
- package/dist/powerlines/src/lib/unplugin/plugin.cjs +71 -0
- package/dist/powerlines/src/lib/unplugin/plugin.mjs +70 -0
- package/dist/powerlines/src/lib/utilities/file-header.cjs +22 -0
- package/dist/powerlines/src/lib/utilities/file-header.mjs +21 -0
- package/dist/powerlines/src/lib/utilities/format.cjs +48 -0
- package/dist/powerlines/src/lib/utilities/format.mjs +46 -0
- package/dist/powerlines/src/lib/utilities/meta.cjs +44 -0
- package/dist/powerlines/src/lib/utilities/meta.mjs +40 -0
- package/dist/powerlines/src/lib/utilities/source-file.cjs +22 -0
- package/dist/powerlines/src/lib/utilities/source-file.mjs +21 -0
- package/dist/powerlines/src/plugin-utils/helpers.cjs +167 -0
- package/dist/powerlines/src/plugin-utils/helpers.mjs +156 -0
- package/dist/powerlines/src/plugin-utils/paths.cjs +36 -0
- package/dist/powerlines/src/plugin-utils/paths.mjs +35 -0
- package/dist/powerlines/src/types/babel.d.mts +2 -0
- package/dist/powerlines/src/types/build.cjs +23 -0
- package/dist/powerlines/src/types/build.mjs +21 -0
- package/dist/powerlines/src/types/commands.cjs +16 -0
- package/dist/powerlines/src/types/commands.mjs +15 -0
- package/dist/{packages/powerlines → powerlines}/src/types/config.d.mts +3 -2
- package/dist/{packages/powerlines → powerlines}/src/types/context.d.mts +4 -4
- package/dist/{packages/powerlines → powerlines}/src/types/fs.d.mts +1 -1
- package/dist/powerlines/src/types/plugin.cjs +33 -0
- package/dist/powerlines/src/types/plugin.mjs +32 -0
- package/dist/{packages/powerlines → powerlines}/src/types/tsconfig.d.mts +1 -1
- package/dist/types/plugin.d.mts +3 -3
- package/package.json +3 -3
- package/dist/_virtual/rolldown_runtime.mjs +0 -32
- package/dist/node_modules/.pnpm/@jridgewell_gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.cjs +0 -2
- package/dist/node_modules/.pnpm/@jridgewell_gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs +0 -4
- package/dist/node_modules/.pnpm/@jridgewell_remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.cjs +0 -2
- package/dist/node_modules/.pnpm/@jridgewell_remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.mjs +0 -4
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +0 -15
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +0 -15
- package/dist/node_modules/.pnpm/@jridgewell_trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.cjs +0 -1
- package/dist/node_modules/.pnpm/@jridgewell_trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs +0 -3
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.cjs +0 -28
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.mjs +0 -23
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.cjs +0 -175
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.mjs +0 -170
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.cjs +0 -871
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.mjs +0 -866
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.cjs +0 -307
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.mjs +0 -302
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.cjs +0 -300
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.mjs +0 -295
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.cjs +0 -60
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.mjs +0 -55
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/context-CehLHpzV.cjs +0 -46
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/context-CehLHpzV.mjs +0 -44
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.cjs +0 -142
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.mjs +0 -140
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.cjs +0 -114
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.mjs +0 -112
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/utils-CuyC8gTr.cjs +0 -59
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/utils-CuyC8gTr.mjs +0 -54
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/webpack-like-BU9ULG6P.cjs +0 -35
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/webpack-like-BU9ULG6P.mjs +0 -33
- package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.cjs +0 -236
- package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.mjs +0 -231
- package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.cjs +0 -54
- package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.mjs +0 -49
- /package/dist/{packages/powerlines → powerlines}/src/internal/helpers/hooks.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/api.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/build.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/commands.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/hooks.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/plugin.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/resolved.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/unplugin.d.mts +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_parse_CRORloGP = require('./parse-CRORloGP.cjs');
|
|
3
|
-
let node_path = require("node:path");
|
|
4
|
-
let node_buffer = require("node:buffer");
|
|
5
|
-
|
|
6
|
-
//#region ../../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/context-CehLHpzV.mjs
|
|
7
|
-
function createBuildContext(compiler, compilation, loaderContext, inputSourceMap) {
|
|
8
|
-
return {
|
|
9
|
-
getNativeBuildContext() {
|
|
10
|
-
return {
|
|
11
|
-
framework: "rspack",
|
|
12
|
-
compiler,
|
|
13
|
-
compilation,
|
|
14
|
-
loaderContext,
|
|
15
|
-
inputSourceMap
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
addWatchFile(file) {
|
|
19
|
-
const cwd = process.cwd();
|
|
20
|
-
compilation.fileDependencies.add((0, node_path.resolve)(cwd, file));
|
|
21
|
-
},
|
|
22
|
-
getWatchFiles() {
|
|
23
|
-
return Array.from(compilation.fileDependencies);
|
|
24
|
-
},
|
|
25
|
-
parse: require_parse_CRORloGP.parse,
|
|
26
|
-
emitFile(emittedFile) {
|
|
27
|
-
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
28
|
-
if (emittedFile.source && outFileName) {
|
|
29
|
-
const { sources } = compilation.compiler.webpack;
|
|
30
|
-
compilation.emitAsset(outFileName, new sources.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : node_buffer.Buffer.from(emittedFile.source)));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function normalizeMessage(error) {
|
|
36
|
-
const err = new Error(typeof error === "string" ? error : error.message);
|
|
37
|
-
if (typeof error === "object") {
|
|
38
|
-
err.stack = error.stack;
|
|
39
|
-
err.cause = error.meta;
|
|
40
|
-
}
|
|
41
|
-
return err;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
|
-
exports.createBuildContext = createBuildContext;
|
|
46
|
-
exports.normalizeMessage = normalizeMessage;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { parse } from "./parse-CRORloGP.mjs";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import { Buffer } from "node:buffer";
|
|
4
|
-
|
|
5
|
-
//#region ../../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/context-CehLHpzV.mjs
|
|
6
|
-
function createBuildContext(compiler, compilation, loaderContext, inputSourceMap) {
|
|
7
|
-
return {
|
|
8
|
-
getNativeBuildContext() {
|
|
9
|
-
return {
|
|
10
|
-
framework: "rspack",
|
|
11
|
-
compiler,
|
|
12
|
-
compilation,
|
|
13
|
-
loaderContext,
|
|
14
|
-
inputSourceMap
|
|
15
|
-
};
|
|
16
|
-
},
|
|
17
|
-
addWatchFile(file) {
|
|
18
|
-
const cwd = process.cwd();
|
|
19
|
-
compilation.fileDependencies.add(resolve(cwd, file));
|
|
20
|
-
},
|
|
21
|
-
getWatchFiles() {
|
|
22
|
-
return Array.from(compilation.fileDependencies);
|
|
23
|
-
},
|
|
24
|
-
parse,
|
|
25
|
-
emitFile(emittedFile) {
|
|
26
|
-
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
27
|
-
if (emittedFile.source && outFileName) {
|
|
28
|
-
const { sources } = compilation.compiler.webpack;
|
|
29
|
-
compilation.emitAsset(outFileName, new sources.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function normalizeMessage(error) {
|
|
35
|
-
const err = new Error(typeof error === "string" ? error : error.message);
|
|
36
|
-
if (typeof error === "object") {
|
|
37
|
-
err.stack = error.stack;
|
|
38
|
-
err.cause = error.meta;
|
|
39
|
-
}
|
|
40
|
-
return err;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
export { createBuildContext, normalizeMessage };
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_parse_CRORloGP = require('./parse-CRORloGP.cjs');
|
|
3
|
-
const require_webpack_like_BU9ULG6P = require('./webpack-like-BU9ULG6P.cjs');
|
|
4
|
-
const require_context_CehLHpzV = require('./context-CehLHpzV.cjs');
|
|
5
|
-
const require_utils_CuyC8gTr = require('./utils-CuyC8gTr.cjs');
|
|
6
|
-
require('../../../../@jridgewell_remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.cjs');
|
|
7
|
-
const require_index = require('../../../../webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.cjs');
|
|
8
|
-
let node_path = require("node:path");
|
|
9
|
-
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
10
|
-
let node_buffer = require("node:buffer");
|
|
11
|
-
let node_fs = require("node:fs");
|
|
12
|
-
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
13
|
-
require("node:process");
|
|
14
|
-
require("node:querystring");
|
|
15
|
-
|
|
16
|
-
//#region ../../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.mjs
|
|
17
|
-
var import_lib = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_index.default, 1);
|
|
18
|
-
const TRANSFORM_LOADER$1 = (0, node_path.resolve)(__dirname, "rspack/loaders/transform.mjs");
|
|
19
|
-
const LOAD_LOADER$1 = (0, node_path.resolve)(__dirname, "rspack/loaders/load.mjs");
|
|
20
|
-
function getRspackPlugin(factory) {
|
|
21
|
-
return (userOptions) => {
|
|
22
|
-
return { apply(compiler) {
|
|
23
|
-
const VIRTUAL_MODULE_PREFIX = (0, node_path.resolve)(compiler.options.context ?? process.cwd(), "node_modules/.virtual", compiler.rspack.experiments.VirtualModulesPlugin ? "" : process.pid.toString());
|
|
24
|
-
const meta = {
|
|
25
|
-
framework: "rspack",
|
|
26
|
-
rspack: { compiler }
|
|
27
|
-
};
|
|
28
|
-
const rawPlugins = require_parse_CRORloGP.toArray(factory(userOptions, meta));
|
|
29
|
-
for (const rawPlugin of rawPlugins) {
|
|
30
|
-
const plugin = Object.assign(rawPlugin, {
|
|
31
|
-
__unpluginMeta: meta,
|
|
32
|
-
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX
|
|
33
|
-
});
|
|
34
|
-
const externalModules = /* @__PURE__ */ new Set();
|
|
35
|
-
if (plugin.resolveId) {
|
|
36
|
-
const createPlugin = (plugin$1) => {
|
|
37
|
-
if (compiler.rspack.experiments.VirtualModulesPlugin) return new compiler.rspack.experiments.VirtualModulesPlugin();
|
|
38
|
-
return new require_utils_CuyC8gTr.FakeVirtualModulesPlugin(plugin$1);
|
|
39
|
-
};
|
|
40
|
-
const vfs = createPlugin(plugin);
|
|
41
|
-
vfs.apply(compiler);
|
|
42
|
-
const vfsModules = /* @__PURE__ */ new Map();
|
|
43
|
-
plugin.__vfsModules = vfsModules;
|
|
44
|
-
plugin.__vfs = vfs;
|
|
45
|
-
compiler.hooks.compilation.tap(plugin.name, (compilation, { normalModuleFactory }) => {
|
|
46
|
-
normalModuleFactory.hooks.resolve.tapPromise(plugin.name, async (resolveData) => {
|
|
47
|
-
const id = require_webpack_like_BU9ULG6P.normalizeAbsolutePath(resolveData.request);
|
|
48
|
-
const requestContext = resolveData.contextInfo;
|
|
49
|
-
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
|
|
50
|
-
const isEntry = requestContext.issuer === "";
|
|
51
|
-
if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
52
|
-
const context = require_context_CehLHpzV.createBuildContext(compiler, compilation);
|
|
53
|
-
let error;
|
|
54
|
-
const pluginContext = {
|
|
55
|
-
error(msg) {
|
|
56
|
-
if (error == null) error = require_context_CehLHpzV.normalizeMessage(msg);
|
|
57
|
-
else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
|
|
58
|
-
},
|
|
59
|
-
warn(msg) {
|
|
60
|
-
console.warn(`unplugin/rspack: warning from resolveId hook: ${msg}`);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const { handler, filter } = require_parse_CRORloGP.normalizeObjectHook("resolveId", plugin.resolveId);
|
|
64
|
-
if (!filter(id)) return;
|
|
65
|
-
const resolveIdResult = await handler.call({
|
|
66
|
-
...context,
|
|
67
|
-
...pluginContext
|
|
68
|
-
}, id, importer, { isEntry });
|
|
69
|
-
if (error != null) throw error;
|
|
70
|
-
if (resolveIdResult == null) return;
|
|
71
|
-
let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
|
|
72
|
-
if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
|
|
73
|
-
let isVirtual = true;
|
|
74
|
-
try {
|
|
75
|
-
(compiler.inputFileSystem?.statSync ?? node_fs.default.statSync)(resolved);
|
|
76
|
-
isVirtual = false;
|
|
77
|
-
} catch {
|
|
78
|
-
isVirtual = !require_utils_CuyC8gTr.isVirtualModuleId(resolved, plugin);
|
|
79
|
-
}
|
|
80
|
-
if (isVirtual) {
|
|
81
|
-
const encodedVirtualPath = require_utils_CuyC8gTr.encodeVirtualModuleId(resolved, plugin);
|
|
82
|
-
if (!vfsModules.has(resolved)) {
|
|
83
|
-
const fsPromise = Promise.resolve(vfs.writeModule(encodedVirtualPath, ""));
|
|
84
|
-
vfsModules.set(resolved, fsPromise);
|
|
85
|
-
await fsPromise;
|
|
86
|
-
} else await vfsModules.get(resolved);
|
|
87
|
-
resolved = encodedVirtualPath;
|
|
88
|
-
}
|
|
89
|
-
resolveData.request = resolved;
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
if (plugin.load) compiler.options.module.rules.unshift({
|
|
94
|
-
enforce: plugin.enforce,
|
|
95
|
-
include(id) {
|
|
96
|
-
if (require_utils_CuyC8gTr.isVirtualModuleId(id, plugin)) id = require_utils_CuyC8gTr.decodeVirtualModuleId(id, plugin);
|
|
97
|
-
if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
|
|
98
|
-
const { filter } = require_parse_CRORloGP.normalizeObjectHook("load", plugin.load);
|
|
99
|
-
if (!filter(id)) return false;
|
|
100
|
-
return !externalModules.has(id);
|
|
101
|
-
},
|
|
102
|
-
use: [{
|
|
103
|
-
loader: LOAD_LOADER$1,
|
|
104
|
-
options: { plugin }
|
|
105
|
-
}],
|
|
106
|
-
type: "javascript/auto"
|
|
107
|
-
});
|
|
108
|
-
if (plugin.transform) compiler.options.module.rules.unshift({
|
|
109
|
-
enforce: plugin.enforce,
|
|
110
|
-
use(data) {
|
|
111
|
-
return require_webpack_like_BU9ULG6P.transformUse(data, plugin, TRANSFORM_LOADER$1);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
if (plugin.rspack) plugin.rspack(compiler);
|
|
115
|
-
if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
|
|
116
|
-
const context = require_context_CehLHpzV.createBuildContext(compiler, compilation);
|
|
117
|
-
if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
|
|
118
|
-
const promises = [];
|
|
119
|
-
if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
|
|
120
|
-
if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
|
|
121
|
-
await Promise.all(promises);
|
|
122
|
-
}
|
|
123
|
-
if (plugin.buildStart) return await plugin.buildStart.call(context);
|
|
124
|
-
});
|
|
125
|
-
if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
|
|
126
|
-
await plugin.buildEnd.call(require_context_CehLHpzV.createBuildContext(compiler, compilation));
|
|
127
|
-
});
|
|
128
|
-
if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
|
|
129
|
-
await plugin.writeBundle();
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
} };
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
const TRANSFORM_LOADER = (0, node_path.resolve)(__dirname, "webpack/loaders/transform.mjs");
|
|
136
|
-
const LOAD_LOADER = (0, node_path.resolve)(__dirname, "webpack/loaders/load.mjs");
|
|
137
|
-
function createRspackPlugin(factory) {
|
|
138
|
-
return getRspackPlugin(factory);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
exports.createRspackPlugin = createRspackPlugin;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { __toESM } from "../../../../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
-
import { normalizeObjectHook, toArray } from "./parse-CRORloGP.mjs";
|
|
3
|
-
import { normalizeAbsolutePath, transformUse } from "./webpack-like-BU9ULG6P.mjs";
|
|
4
|
-
import { createBuildContext, normalizeMessage } from "./context-CehLHpzV.mjs";
|
|
5
|
-
import { FakeVirtualModulesPlugin, decodeVirtualModuleId, encodeVirtualModuleId, isVirtualModuleId } from "./utils-CuyC8gTr.mjs";
|
|
6
|
-
import "../../../../@jridgewell_remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.mjs";
|
|
7
|
-
import { require_lib } from "../../../../webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.mjs";
|
|
8
|
-
import { isAbsolute, resolve } from "node:path";
|
|
9
|
-
import { Buffer } from "node:buffer";
|
|
10
|
-
import fs from "node:fs";
|
|
11
|
-
import "node:process";
|
|
12
|
-
import "node:querystring";
|
|
13
|
-
|
|
14
|
-
//#region ../../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.mjs
|
|
15
|
-
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
16
|
-
const TRANSFORM_LOADER$1 = resolve(import.meta.dirname, "rspack/loaders/transform.mjs");
|
|
17
|
-
const LOAD_LOADER$1 = resolve(import.meta.dirname, "rspack/loaders/load.mjs");
|
|
18
|
-
function getRspackPlugin(factory) {
|
|
19
|
-
return (userOptions) => {
|
|
20
|
-
return { apply(compiler) {
|
|
21
|
-
const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process.cwd(), "node_modules/.virtual", compiler.rspack.experiments.VirtualModulesPlugin ? "" : process.pid.toString());
|
|
22
|
-
const meta = {
|
|
23
|
-
framework: "rspack",
|
|
24
|
-
rspack: { compiler }
|
|
25
|
-
};
|
|
26
|
-
const rawPlugins = toArray(factory(userOptions, meta));
|
|
27
|
-
for (const rawPlugin of rawPlugins) {
|
|
28
|
-
const plugin = Object.assign(rawPlugin, {
|
|
29
|
-
__unpluginMeta: meta,
|
|
30
|
-
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX
|
|
31
|
-
});
|
|
32
|
-
const externalModules = /* @__PURE__ */ new Set();
|
|
33
|
-
if (plugin.resolveId) {
|
|
34
|
-
const createPlugin = (plugin$1) => {
|
|
35
|
-
if (compiler.rspack.experiments.VirtualModulesPlugin) return new compiler.rspack.experiments.VirtualModulesPlugin();
|
|
36
|
-
return new FakeVirtualModulesPlugin(plugin$1);
|
|
37
|
-
};
|
|
38
|
-
const vfs = createPlugin(plugin);
|
|
39
|
-
vfs.apply(compiler);
|
|
40
|
-
const vfsModules = /* @__PURE__ */ new Map();
|
|
41
|
-
plugin.__vfsModules = vfsModules;
|
|
42
|
-
plugin.__vfs = vfs;
|
|
43
|
-
compiler.hooks.compilation.tap(plugin.name, (compilation, { normalModuleFactory }) => {
|
|
44
|
-
normalModuleFactory.hooks.resolve.tapPromise(plugin.name, async (resolveData) => {
|
|
45
|
-
const id = normalizeAbsolutePath(resolveData.request);
|
|
46
|
-
const requestContext = resolveData.contextInfo;
|
|
47
|
-
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
|
|
48
|
-
const isEntry = requestContext.issuer === "";
|
|
49
|
-
if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
50
|
-
const context = createBuildContext(compiler, compilation);
|
|
51
|
-
let error;
|
|
52
|
-
const pluginContext = {
|
|
53
|
-
error(msg) {
|
|
54
|
-
if (error == null) error = normalizeMessage(msg);
|
|
55
|
-
else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
|
|
56
|
-
},
|
|
57
|
-
warn(msg) {
|
|
58
|
-
console.warn(`unplugin/rspack: warning from resolveId hook: ${msg}`);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
|
|
62
|
-
if (!filter(id)) return;
|
|
63
|
-
const resolveIdResult = await handler.call({
|
|
64
|
-
...context,
|
|
65
|
-
...pluginContext
|
|
66
|
-
}, id, importer, { isEntry });
|
|
67
|
-
if (error != null) throw error;
|
|
68
|
-
if (resolveIdResult == null) return;
|
|
69
|
-
let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
|
|
70
|
-
if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
|
|
71
|
-
let isVirtual = true;
|
|
72
|
-
try {
|
|
73
|
-
(compiler.inputFileSystem?.statSync ?? fs.statSync)(resolved);
|
|
74
|
-
isVirtual = false;
|
|
75
|
-
} catch {
|
|
76
|
-
isVirtual = !isVirtualModuleId(resolved, plugin);
|
|
77
|
-
}
|
|
78
|
-
if (isVirtual) {
|
|
79
|
-
const encodedVirtualPath = encodeVirtualModuleId(resolved, plugin);
|
|
80
|
-
if (!vfsModules.has(resolved)) {
|
|
81
|
-
const fsPromise = Promise.resolve(vfs.writeModule(encodedVirtualPath, ""));
|
|
82
|
-
vfsModules.set(resolved, fsPromise);
|
|
83
|
-
await fsPromise;
|
|
84
|
-
} else await vfsModules.get(resolved);
|
|
85
|
-
resolved = encodedVirtualPath;
|
|
86
|
-
}
|
|
87
|
-
resolveData.request = resolved;
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
if (plugin.load) compiler.options.module.rules.unshift({
|
|
92
|
-
enforce: plugin.enforce,
|
|
93
|
-
include(id) {
|
|
94
|
-
if (isVirtualModuleId(id, plugin)) id = decodeVirtualModuleId(id, plugin);
|
|
95
|
-
if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
|
|
96
|
-
const { filter } = normalizeObjectHook("load", plugin.load);
|
|
97
|
-
if (!filter(id)) return false;
|
|
98
|
-
return !externalModules.has(id);
|
|
99
|
-
},
|
|
100
|
-
use: [{
|
|
101
|
-
loader: LOAD_LOADER$1,
|
|
102
|
-
options: { plugin }
|
|
103
|
-
}],
|
|
104
|
-
type: "javascript/auto"
|
|
105
|
-
});
|
|
106
|
-
if (plugin.transform) compiler.options.module.rules.unshift({
|
|
107
|
-
enforce: plugin.enforce,
|
|
108
|
-
use(data) {
|
|
109
|
-
return transformUse(data, plugin, TRANSFORM_LOADER$1);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
if (plugin.rspack) plugin.rspack(compiler);
|
|
113
|
-
if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
|
|
114
|
-
const context = createBuildContext(compiler, compilation);
|
|
115
|
-
if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
|
|
116
|
-
const promises = [];
|
|
117
|
-
if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
|
|
118
|
-
if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
|
|
119
|
-
await Promise.all(promises);
|
|
120
|
-
}
|
|
121
|
-
if (plugin.buildStart) return await plugin.buildStart.call(context);
|
|
122
|
-
});
|
|
123
|
-
if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
|
|
124
|
-
await plugin.buildEnd.call(createBuildContext(compiler, compilation));
|
|
125
|
-
});
|
|
126
|
-
if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
|
|
127
|
-
await plugin.writeBundle();
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
} };
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
const TRANSFORM_LOADER = resolve(import.meta.dirname, "webpack/loaders/transform.mjs");
|
|
134
|
-
const LOAD_LOADER = resolve(import.meta.dirname, "webpack/loaders/load.mjs");
|
|
135
|
-
function createRspackPlugin(factory) {
|
|
136
|
-
return getRspackPlugin(factory);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
//#endregion
|
|
140
|
-
export { createRspackPlugin };
|
package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.cjs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_index = require('../../../../picomatch@4.0.3/node_modules/picomatch/index.cjs');
|
|
3
|
-
let node_path = require("node:path");
|
|
4
|
-
|
|
5
|
-
//#region ../../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.mjs
|
|
6
|
-
var import_picomatch = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_index.default, 1);
|
|
7
|
-
function toArray(array) {
|
|
8
|
-
array = array || [];
|
|
9
|
-
if (Array.isArray(array)) return array;
|
|
10
|
-
return [array];
|
|
11
|
-
}
|
|
12
|
-
const BACKSLASH_REGEX = /\\/g;
|
|
13
|
-
function normalize$1(path$1) {
|
|
14
|
-
return path$1.replace(BACKSLASH_REGEX, "/");
|
|
15
|
-
}
|
|
16
|
-
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
|
|
17
|
-
function isAbsolute$1(path$1) {
|
|
18
|
-
return ABSOLUTE_PATH_REGEX.test(path$1);
|
|
19
|
-
}
|
|
20
|
-
function getMatcherString(glob, cwd) {
|
|
21
|
-
if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
|
|
22
|
-
return normalize$1((0, node_path.resolve)(cwd, glob));
|
|
23
|
-
}
|
|
24
|
-
function patternToIdFilter(pattern) {
|
|
25
|
-
if (pattern instanceof RegExp) return (id) => {
|
|
26
|
-
const normalizedId = normalize$1(id);
|
|
27
|
-
const result = pattern.test(normalizedId);
|
|
28
|
-
pattern.lastIndex = 0;
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
const matcher = (0, import_picomatch.default)(getMatcherString(pattern, process.cwd()), { dot: true });
|
|
32
|
-
return (id) => {
|
|
33
|
-
return matcher(normalize$1(id));
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function patternToCodeFilter(pattern) {
|
|
37
|
-
if (pattern instanceof RegExp) return (code) => {
|
|
38
|
-
const result = pattern.test(code);
|
|
39
|
-
pattern.lastIndex = 0;
|
|
40
|
-
return result;
|
|
41
|
-
};
|
|
42
|
-
return (code) => code.includes(pattern);
|
|
43
|
-
}
|
|
44
|
-
function createFilter(exclude, include) {
|
|
45
|
-
if (!exclude && !include) return;
|
|
46
|
-
return (input) => {
|
|
47
|
-
if (exclude?.some((filter) => filter(input))) return false;
|
|
48
|
-
if (include?.some((filter) => filter(input))) return true;
|
|
49
|
-
return !(include && include.length > 0);
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function normalizeFilter(filter) {
|
|
53
|
-
if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
|
|
54
|
-
if (Array.isArray(filter)) return { include: filter };
|
|
55
|
-
return {
|
|
56
|
-
exclude: filter.exclude ? toArray(filter.exclude) : void 0,
|
|
57
|
-
include: filter.include ? toArray(filter.include) : void 0
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function createIdFilter(filter) {
|
|
61
|
-
if (!filter) return;
|
|
62
|
-
const { exclude, include } = normalizeFilter(filter);
|
|
63
|
-
const excludeFilter = exclude?.map(patternToIdFilter);
|
|
64
|
-
const includeFilter = include?.map(patternToIdFilter);
|
|
65
|
-
return createFilter(excludeFilter, includeFilter);
|
|
66
|
-
}
|
|
67
|
-
function createCodeFilter(filter) {
|
|
68
|
-
if (!filter) return;
|
|
69
|
-
const { exclude, include } = normalizeFilter(filter);
|
|
70
|
-
const excludeFilter = exclude?.map(patternToCodeFilter);
|
|
71
|
-
const includeFilter = include?.map(patternToCodeFilter);
|
|
72
|
-
return createFilter(excludeFilter, includeFilter);
|
|
73
|
-
}
|
|
74
|
-
function createFilterForId(filter) {
|
|
75
|
-
const filterFunction = createIdFilter(filter);
|
|
76
|
-
return filterFunction ? (id) => !!filterFunction(id) : void 0;
|
|
77
|
-
}
|
|
78
|
-
function createFilterForTransform(idFilter, codeFilter) {
|
|
79
|
-
if (!idFilter && !codeFilter) return;
|
|
80
|
-
const idFilterFunction = createIdFilter(idFilter);
|
|
81
|
-
const codeFilterFunction = createCodeFilter(codeFilter);
|
|
82
|
-
return (id, code) => {
|
|
83
|
-
let fallback = true;
|
|
84
|
-
if (idFilterFunction) fallback &&= idFilterFunction(id);
|
|
85
|
-
if (!fallback) return false;
|
|
86
|
-
if (codeFilterFunction) fallback &&= codeFilterFunction(code);
|
|
87
|
-
return fallback;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function normalizeObjectHook(name, hook) {
|
|
91
|
-
let handler;
|
|
92
|
-
let filter;
|
|
93
|
-
if (typeof hook === "function") handler = hook;
|
|
94
|
-
else {
|
|
95
|
-
handler = hook.handler;
|
|
96
|
-
const hookFilter = hook.filter;
|
|
97
|
-
if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
|
|
98
|
-
else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
handler,
|
|
102
|
-
filter: filter || (() => true)
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
let parseImpl;
|
|
106
|
-
function parse(code, opts = {}) {
|
|
107
|
-
if (!parseImpl) throw new Error("Parse implementation is not set. Please call setParseImpl first.");
|
|
108
|
-
return parseImpl(code, opts);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
exports.normalizeObjectHook = normalizeObjectHook;
|
|
113
|
-
exports.parse = parse;
|
|
114
|
-
exports.toArray = toArray;
|
package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.mjs
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { __toESM } from "../../../../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
-
import { require_picomatch } from "../../../../picomatch@4.0.3/node_modules/picomatch/index.mjs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
|
|
5
|
-
//#region ../../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.mjs
|
|
6
|
-
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
|
|
7
|
-
function toArray(array) {
|
|
8
|
-
array = array || [];
|
|
9
|
-
if (Array.isArray(array)) return array;
|
|
10
|
-
return [array];
|
|
11
|
-
}
|
|
12
|
-
const BACKSLASH_REGEX = /\\/g;
|
|
13
|
-
function normalize$1(path$1) {
|
|
14
|
-
return path$1.replace(BACKSLASH_REGEX, "/");
|
|
15
|
-
}
|
|
16
|
-
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
|
|
17
|
-
function isAbsolute$1(path$1) {
|
|
18
|
-
return ABSOLUTE_PATH_REGEX.test(path$1);
|
|
19
|
-
}
|
|
20
|
-
function getMatcherString(glob, cwd) {
|
|
21
|
-
if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
|
|
22
|
-
return normalize$1(resolve(cwd, glob));
|
|
23
|
-
}
|
|
24
|
-
function patternToIdFilter(pattern) {
|
|
25
|
-
if (pattern instanceof RegExp) return (id) => {
|
|
26
|
-
const normalizedId = normalize$1(id);
|
|
27
|
-
const result = pattern.test(normalizedId);
|
|
28
|
-
pattern.lastIndex = 0;
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
const matcher = (0, import_picomatch.default)(getMatcherString(pattern, process.cwd()), { dot: true });
|
|
32
|
-
return (id) => {
|
|
33
|
-
return matcher(normalize$1(id));
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function patternToCodeFilter(pattern) {
|
|
37
|
-
if (pattern instanceof RegExp) return (code) => {
|
|
38
|
-
const result = pattern.test(code);
|
|
39
|
-
pattern.lastIndex = 0;
|
|
40
|
-
return result;
|
|
41
|
-
};
|
|
42
|
-
return (code) => code.includes(pattern);
|
|
43
|
-
}
|
|
44
|
-
function createFilter(exclude, include) {
|
|
45
|
-
if (!exclude && !include) return;
|
|
46
|
-
return (input) => {
|
|
47
|
-
if (exclude?.some((filter) => filter(input))) return false;
|
|
48
|
-
if (include?.some((filter) => filter(input))) return true;
|
|
49
|
-
return !(include && include.length > 0);
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function normalizeFilter(filter) {
|
|
53
|
-
if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
|
|
54
|
-
if (Array.isArray(filter)) return { include: filter };
|
|
55
|
-
return {
|
|
56
|
-
exclude: filter.exclude ? toArray(filter.exclude) : void 0,
|
|
57
|
-
include: filter.include ? toArray(filter.include) : void 0
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function createIdFilter(filter) {
|
|
61
|
-
if (!filter) return;
|
|
62
|
-
const { exclude, include } = normalizeFilter(filter);
|
|
63
|
-
const excludeFilter = exclude?.map(patternToIdFilter);
|
|
64
|
-
const includeFilter = include?.map(patternToIdFilter);
|
|
65
|
-
return createFilter(excludeFilter, includeFilter);
|
|
66
|
-
}
|
|
67
|
-
function createCodeFilter(filter) {
|
|
68
|
-
if (!filter) return;
|
|
69
|
-
const { exclude, include } = normalizeFilter(filter);
|
|
70
|
-
const excludeFilter = exclude?.map(patternToCodeFilter);
|
|
71
|
-
const includeFilter = include?.map(patternToCodeFilter);
|
|
72
|
-
return createFilter(excludeFilter, includeFilter);
|
|
73
|
-
}
|
|
74
|
-
function createFilterForId(filter) {
|
|
75
|
-
const filterFunction = createIdFilter(filter);
|
|
76
|
-
return filterFunction ? (id) => !!filterFunction(id) : void 0;
|
|
77
|
-
}
|
|
78
|
-
function createFilterForTransform(idFilter, codeFilter) {
|
|
79
|
-
if (!idFilter && !codeFilter) return;
|
|
80
|
-
const idFilterFunction = createIdFilter(idFilter);
|
|
81
|
-
const codeFilterFunction = createCodeFilter(codeFilter);
|
|
82
|
-
return (id, code) => {
|
|
83
|
-
let fallback = true;
|
|
84
|
-
if (idFilterFunction) fallback &&= idFilterFunction(id);
|
|
85
|
-
if (!fallback) return false;
|
|
86
|
-
if (codeFilterFunction) fallback &&= codeFilterFunction(code);
|
|
87
|
-
return fallback;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function normalizeObjectHook(name, hook) {
|
|
91
|
-
let handler;
|
|
92
|
-
let filter;
|
|
93
|
-
if (typeof hook === "function") handler = hook;
|
|
94
|
-
else {
|
|
95
|
-
handler = hook.handler;
|
|
96
|
-
const hookFilter = hook.filter;
|
|
97
|
-
if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
|
|
98
|
-
else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
handler,
|
|
102
|
-
filter: filter || (() => true)
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
let parseImpl;
|
|
106
|
-
function parse(code, opts = {}) {
|
|
107
|
-
if (!parseImpl) throw new Error("Parse implementation is not set. Please call setParseImpl first.");
|
|
108
|
-
return parseImpl(code, opts);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
export { normalizeObjectHook, parse, toArray };
|
package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/utils-CuyC8gTr.cjs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let node_path = require("node:path");
|
|
3
|
-
let node_fs = require("node:fs");
|
|
4
|
-
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
5
|
-
|
|
6
|
-
//#region ../../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/utils-CuyC8gTr.mjs
|
|
7
|
-
function encodeVirtualModuleId(id, plugin) {
|
|
8
|
-
return (0, node_path.resolve)(plugin.__virtualModulePrefix, encodeURIComponent(id));
|
|
9
|
-
}
|
|
10
|
-
function decodeVirtualModuleId(encoded, _plugin) {
|
|
11
|
-
return decodeURIComponent((0, node_path.basename)(encoded));
|
|
12
|
-
}
|
|
13
|
-
function isVirtualModuleId(encoded, plugin) {
|
|
14
|
-
return (0, node_path.dirname)(encoded) === plugin.__virtualModulePrefix;
|
|
15
|
-
}
|
|
16
|
-
var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin$1 {
|
|
17
|
-
name = "FakeVirtualModulesPlugin";
|
|
18
|
-
static counters = /* @__PURE__ */ new Map();
|
|
19
|
-
static initCleanup = false;
|
|
20
|
-
constructor(plugin) {
|
|
21
|
-
this.plugin = plugin;
|
|
22
|
-
if (!FakeVirtualModulesPlugin$1.initCleanup) {
|
|
23
|
-
FakeVirtualModulesPlugin$1.initCleanup = true;
|
|
24
|
-
process.once("exit", () => {
|
|
25
|
-
FakeVirtualModulesPlugin$1.counters.forEach((_, dir) => {
|
|
26
|
-
node_fs.default.rmSync(dir, {
|
|
27
|
-
recursive: true,
|
|
28
|
-
force: true
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
apply(compiler) {
|
|
35
|
-
const dir = this.plugin.__virtualModulePrefix;
|
|
36
|
-
if (!node_fs.default.existsSync(dir)) node_fs.default.mkdirSync(dir, { recursive: true });
|
|
37
|
-
const counter = FakeVirtualModulesPlugin$1.counters.get(dir) ?? 0;
|
|
38
|
-
FakeVirtualModulesPlugin$1.counters.set(dir, counter + 1);
|
|
39
|
-
compiler.hooks.shutdown.tap(this.name, () => {
|
|
40
|
-
const counter$1 = (FakeVirtualModulesPlugin$1.counters.get(dir) ?? 1) - 1;
|
|
41
|
-
if (counter$1 === 0) {
|
|
42
|
-
FakeVirtualModulesPlugin$1.counters.delete(dir);
|
|
43
|
-
node_fs.default.rmSync(dir, {
|
|
44
|
-
recursive: true,
|
|
45
|
-
force: true
|
|
46
|
-
});
|
|
47
|
-
} else FakeVirtualModulesPlugin$1.counters.set(dir, counter$1);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
async writeModule(file) {
|
|
51
|
-
return node_fs.default.promises.writeFile(file, "");
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
exports.FakeVirtualModulesPlugin = FakeVirtualModulesPlugin;
|
|
57
|
-
exports.decodeVirtualModuleId = decodeVirtualModuleId;
|
|
58
|
-
exports.encodeVirtualModuleId = encodeVirtualModuleId;
|
|
59
|
-
exports.isVirtualModuleId = isVirtualModuleId;
|