初始化
This commit is contained in:
126
uni_modules/UniDevTools/node_modules/unplugin/dist/index.d.mts
generated
vendored
Normal file
126
uni_modules/UniDevTools/node_modules/unplugin/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
import * as _rspack_core_dist_config_types from '@rspack/core/dist/config/types';
|
||||
import * as webpack from 'webpack';
|
||||
import { Compiler, WebpackPluginInstance } from 'webpack';
|
||||
export { Compiler as WebpackCompiler, WebpackPluginInstance } from 'webpack';
|
||||
import * as vite from 'vite';
|
||||
import { Plugin as Plugin$1 } from 'vite';
|
||||
export { Plugin as VitePlugin } from 'vite';
|
||||
import * as rollup from 'rollup';
|
||||
import { SourceMapInput, EmittedAsset, AcornNode, Plugin, PluginContextMeta } from 'rollup';
|
||||
export { Plugin as RollupPlugin } from 'rollup';
|
||||
import * as esbuild from 'esbuild';
|
||||
import { Plugin as Plugin$2, PluginBuild } from 'esbuild';
|
||||
export { Plugin as EsbuildPlugin } from 'esbuild';
|
||||
import { Compiler as Compiler$1, RspackPluginInstance } from '@rspack/core';
|
||||
export { Compiler as RspackCompiler, RspackPluginInstance } from '@rspack/core';
|
||||
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
||||
|
||||
type Thenable<T> = T | Promise<T>;
|
||||
interface SourceMapCompact {
|
||||
file?: string;
|
||||
mappings: string;
|
||||
names: string[];
|
||||
sourceRoot?: string;
|
||||
sources: string[];
|
||||
sourcesContent?: (string | null)[];
|
||||
version: number;
|
||||
}
|
||||
type TransformResult = string | {
|
||||
code: string;
|
||||
map?: SourceMapInput | SourceMapCompact | null;
|
||||
} | null | undefined;
|
||||
interface ExternalIdResult {
|
||||
id: string;
|
||||
external?: boolean;
|
||||
}
|
||||
interface UnpluginBuildContext {
|
||||
addWatchFile: (id: string) => void;
|
||||
emitFile: (emittedFile: EmittedAsset) => void;
|
||||
getWatchFiles: () => string[];
|
||||
parse: (input: string, options?: any) => AcornNode;
|
||||
}
|
||||
interface UnpluginOptions {
|
||||
name: string;
|
||||
enforce?: 'post' | 'pre' | undefined;
|
||||
buildStart?: (this: UnpluginBuildContext) => Promise<void> | void;
|
||||
buildEnd?: (this: UnpluginBuildContext) => Promise<void> | void;
|
||||
transform?: (this: UnpluginBuildContext & UnpluginContext, code: string, id: string) => Thenable<TransformResult>;
|
||||
load?: (this: UnpluginBuildContext & UnpluginContext, id: string) => Thenable<TransformResult>;
|
||||
resolveId?: (id: string, importer: string | undefined, options: {
|
||||
isEntry: boolean;
|
||||
}) => Thenable<string | ExternalIdResult | null | undefined>;
|
||||
watchChange?: (this: UnpluginBuildContext, id: string, change: {
|
||||
event: 'create' | 'update' | 'delete';
|
||||
}) => void;
|
||||
writeBundle?: (this: void) => Promise<void> | void;
|
||||
/**
|
||||
* Custom predicate function to filter modules to be loaded.
|
||||
* When omitted, all modules will be included (might have potential perf impact on Webpack).
|
||||
*/
|
||||
loadInclude?: (id: string) => boolean | null | undefined;
|
||||
/**
|
||||
* Custom predicate function to filter modules to be transformed.
|
||||
* When omitted, all modules will be included (might have potential perf impact on Webpack).
|
||||
*/
|
||||
transformInclude?: (id: string) => boolean | null | undefined;
|
||||
rollup?: Partial<Plugin>;
|
||||
webpack?: (compiler: Compiler) => void;
|
||||
rspack?: (compiler: Compiler$1) => void;
|
||||
vite?: Partial<Plugin$1>;
|
||||
esbuild?: {
|
||||
onResolveFilter?: RegExp;
|
||||
onLoadFilter?: RegExp;
|
||||
setup?: Plugin$2['setup'];
|
||||
};
|
||||
}
|
||||
interface ResolvedUnpluginOptions extends UnpluginOptions {
|
||||
__vfs?: VirtualModulesPlugin;
|
||||
__vfsModules?: Set<string>;
|
||||
__virtualModulePrefix: string;
|
||||
}
|
||||
type UnpluginFactory<UserOptions, Nested extends boolean = boolean> = (options: UserOptions, meta: UnpluginContextMeta) => Nested extends true ? Array<UnpluginOptions> : UnpluginOptions;
|
||||
type UnpluginFactoryOutput<UserOptions, Return> = undefined extends UserOptions ? (options?: UserOptions) => Return : (options: UserOptions) => Return;
|
||||
interface UnpluginInstance<UserOptions, Nested extends boolean = boolean> {
|
||||
rollup: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin> : Plugin>;
|
||||
vite: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin$1> : Plugin$1>;
|
||||
webpack: UnpluginFactoryOutput<UserOptions, WebpackPluginInstance>;
|
||||
rspack: UnpluginFactoryOutput<UserOptions, RspackPluginInstance>;
|
||||
esbuild: UnpluginFactoryOutput<UserOptions, Plugin$2>;
|
||||
raw: UnpluginFactory<UserOptions, Nested>;
|
||||
}
|
||||
type UnpluginContextMeta = Partial<PluginContextMeta> & ({
|
||||
framework: 'rollup' | 'vite';
|
||||
} | {
|
||||
framework: 'webpack';
|
||||
webpack: {
|
||||
compiler: Compiler;
|
||||
};
|
||||
} | {
|
||||
framework: 'esbuild';
|
||||
build?: PluginBuild;
|
||||
/** Set the host plugin name of esbuild when returning multiple plugins */
|
||||
esbuildHostName?: string;
|
||||
} | {
|
||||
framework: 'rspack';
|
||||
rspack: {
|
||||
compiler: Compiler$1;
|
||||
};
|
||||
});
|
||||
interface UnpluginContext {
|
||||
error(message: any): void;
|
||||
warn(message: any): void;
|
||||
}
|
||||
declare module 'webpack' {
|
||||
interface Compiler {
|
||||
$unpluginContext: Record<string, ResolvedUnpluginOptions>;
|
||||
}
|
||||
}
|
||||
|
||||
declare function createUnplugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions, Nested>;
|
||||
declare function creteEsbuildPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, esbuild.Plugin>;
|
||||
declare function creteRollupPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, Nested extends true ? rollup.Plugin[] : rollup.Plugin>;
|
||||
declare function creteVitePlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, Nested extends true ? vite.Plugin[] : vite.Plugin>;
|
||||
declare function creteWebpackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, webpack.WebpackPluginInstance>;
|
||||
declare function creteRspackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, _rspack_core_dist_config_types.RspackPluginInstance>;
|
||||
|
||||
export { ExternalIdResult, ResolvedUnpluginOptions, SourceMapCompact, Thenable, TransformResult, UnpluginBuildContext, UnpluginContext, UnpluginContextMeta, UnpluginFactory, UnpluginFactoryOutput, UnpluginInstance, UnpluginOptions, createUnplugin, creteEsbuildPlugin, creteRollupPlugin, creteRspackPlugin, creteVitePlugin, creteWebpackPlugin };
|
||||
126
uni_modules/UniDevTools/node_modules/unplugin/dist/index.d.ts
generated
vendored
Normal file
126
uni_modules/UniDevTools/node_modules/unplugin/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
import * as _rspack_core_dist_config_types from '@rspack/core/dist/config/types';
|
||||
import * as webpack from 'webpack';
|
||||
import { Compiler, WebpackPluginInstance } from 'webpack';
|
||||
export { Compiler as WebpackCompiler, WebpackPluginInstance } from 'webpack';
|
||||
import * as vite from 'vite';
|
||||
import { Plugin as Plugin$1 } from 'vite';
|
||||
export { Plugin as VitePlugin } from 'vite';
|
||||
import * as rollup from 'rollup';
|
||||
import { SourceMapInput, EmittedAsset, AcornNode, Plugin, PluginContextMeta } from 'rollup';
|
||||
export { Plugin as RollupPlugin } from 'rollup';
|
||||
import * as esbuild from 'esbuild';
|
||||
import { Plugin as Plugin$2, PluginBuild } from 'esbuild';
|
||||
export { Plugin as EsbuildPlugin } from 'esbuild';
|
||||
import { Compiler as Compiler$1, RspackPluginInstance } from '@rspack/core';
|
||||
export { Compiler as RspackCompiler, RspackPluginInstance } from '@rspack/core';
|
||||
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
||||
|
||||
type Thenable<T> = T | Promise<T>;
|
||||
interface SourceMapCompact {
|
||||
file?: string;
|
||||
mappings: string;
|
||||
names: string[];
|
||||
sourceRoot?: string;
|
||||
sources: string[];
|
||||
sourcesContent?: (string | null)[];
|
||||
version: number;
|
||||
}
|
||||
type TransformResult = string | {
|
||||
code: string;
|
||||
map?: SourceMapInput | SourceMapCompact | null;
|
||||
} | null | undefined;
|
||||
interface ExternalIdResult {
|
||||
id: string;
|
||||
external?: boolean;
|
||||
}
|
||||
interface UnpluginBuildContext {
|
||||
addWatchFile: (id: string) => void;
|
||||
emitFile: (emittedFile: EmittedAsset) => void;
|
||||
getWatchFiles: () => string[];
|
||||
parse: (input: string, options?: any) => AcornNode;
|
||||
}
|
||||
interface UnpluginOptions {
|
||||
name: string;
|
||||
enforce?: 'post' | 'pre' | undefined;
|
||||
buildStart?: (this: UnpluginBuildContext) => Promise<void> | void;
|
||||
buildEnd?: (this: UnpluginBuildContext) => Promise<void> | void;
|
||||
transform?: (this: UnpluginBuildContext & UnpluginContext, code: string, id: string) => Thenable<TransformResult>;
|
||||
load?: (this: UnpluginBuildContext & UnpluginContext, id: string) => Thenable<TransformResult>;
|
||||
resolveId?: (id: string, importer: string | undefined, options: {
|
||||
isEntry: boolean;
|
||||
}) => Thenable<string | ExternalIdResult | null | undefined>;
|
||||
watchChange?: (this: UnpluginBuildContext, id: string, change: {
|
||||
event: 'create' | 'update' | 'delete';
|
||||
}) => void;
|
||||
writeBundle?: (this: void) => Promise<void> | void;
|
||||
/**
|
||||
* Custom predicate function to filter modules to be loaded.
|
||||
* When omitted, all modules will be included (might have potential perf impact on Webpack).
|
||||
*/
|
||||
loadInclude?: (id: string) => boolean | null | undefined;
|
||||
/**
|
||||
* Custom predicate function to filter modules to be transformed.
|
||||
* When omitted, all modules will be included (might have potential perf impact on Webpack).
|
||||
*/
|
||||
transformInclude?: (id: string) => boolean | null | undefined;
|
||||
rollup?: Partial<Plugin>;
|
||||
webpack?: (compiler: Compiler) => void;
|
||||
rspack?: (compiler: Compiler$1) => void;
|
||||
vite?: Partial<Plugin$1>;
|
||||
esbuild?: {
|
||||
onResolveFilter?: RegExp;
|
||||
onLoadFilter?: RegExp;
|
||||
setup?: Plugin$2['setup'];
|
||||
};
|
||||
}
|
||||
interface ResolvedUnpluginOptions extends UnpluginOptions {
|
||||
__vfs?: VirtualModulesPlugin;
|
||||
__vfsModules?: Set<string>;
|
||||
__virtualModulePrefix: string;
|
||||
}
|
||||
type UnpluginFactory<UserOptions, Nested extends boolean = boolean> = (options: UserOptions, meta: UnpluginContextMeta) => Nested extends true ? Array<UnpluginOptions> : UnpluginOptions;
|
||||
type UnpluginFactoryOutput<UserOptions, Return> = undefined extends UserOptions ? (options?: UserOptions) => Return : (options: UserOptions) => Return;
|
||||
interface UnpluginInstance<UserOptions, Nested extends boolean = boolean> {
|
||||
rollup: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin> : Plugin>;
|
||||
vite: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin$1> : Plugin$1>;
|
||||
webpack: UnpluginFactoryOutput<UserOptions, WebpackPluginInstance>;
|
||||
rspack: UnpluginFactoryOutput<UserOptions, RspackPluginInstance>;
|
||||
esbuild: UnpluginFactoryOutput<UserOptions, Plugin$2>;
|
||||
raw: UnpluginFactory<UserOptions, Nested>;
|
||||
}
|
||||
type UnpluginContextMeta = Partial<PluginContextMeta> & ({
|
||||
framework: 'rollup' | 'vite';
|
||||
} | {
|
||||
framework: 'webpack';
|
||||
webpack: {
|
||||
compiler: Compiler;
|
||||
};
|
||||
} | {
|
||||
framework: 'esbuild';
|
||||
build?: PluginBuild;
|
||||
/** Set the host plugin name of esbuild when returning multiple plugins */
|
||||
esbuildHostName?: string;
|
||||
} | {
|
||||
framework: 'rspack';
|
||||
rspack: {
|
||||
compiler: Compiler$1;
|
||||
};
|
||||
});
|
||||
interface UnpluginContext {
|
||||
error(message: any): void;
|
||||
warn(message: any): void;
|
||||
}
|
||||
declare module 'webpack' {
|
||||
interface Compiler {
|
||||
$unpluginContext: Record<string, ResolvedUnpluginOptions>;
|
||||
}
|
||||
}
|
||||
|
||||
declare function createUnplugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions, Nested>;
|
||||
declare function creteEsbuildPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, esbuild.Plugin>;
|
||||
declare function creteRollupPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, Nested extends true ? rollup.Plugin[] : rollup.Plugin>;
|
||||
declare function creteVitePlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, Nested extends true ? vite.Plugin[] : vite.Plugin>;
|
||||
declare function creteWebpackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, webpack.WebpackPluginInstance>;
|
||||
declare function creteRspackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, _rspack_core_dist_config_types.RspackPluginInstance>;
|
||||
|
||||
export { ExternalIdResult, ResolvedUnpluginOptions, SourceMapCompact, Thenable, TransformResult, UnpluginBuildContext, UnpluginContext, UnpluginContextMeta, UnpluginFactory, UnpluginFactoryOutput, UnpluginInstance, UnpluginOptions, createUnplugin, creteEsbuildPlugin, creteRollupPlugin, creteRspackPlugin, creteVitePlugin, creteWebpackPlugin };
|
||||
1681
uni_modules/UniDevTools/node_modules/unplugin/dist/index.js
generated
vendored
Normal file
1681
uni_modules/UniDevTools/node_modules/unplugin/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1646
uni_modules/UniDevTools/node_modules/unplugin/dist/index.mjs
generated
vendored
Normal file
1646
uni_modules/UniDevTools/node_modules/unplugin/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/load.d.mts
generated
vendored
Normal file
5
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/load.d.mts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { LoaderContext } from '@rspack/core';
|
||||
|
||||
declare function load(this: LoaderContext, source: string, map: any): Promise<void>;
|
||||
|
||||
export { load as default };
|
||||
5
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/load.d.ts
generated
vendored
Normal file
5
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/load.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { LoaderContext } from '@rspack/core';
|
||||
|
||||
declare function load(this: LoaderContext, source: string, map: any): Promise<void>;
|
||||
|
||||
export { load as default };
|
||||
106
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/load.js
generated
vendored
Normal file
106
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/load.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/rspack/loaders/load.ts
|
||||
var load_exports = {};
|
||||
__export(load_exports, {
|
||||
default: () => load
|
||||
});
|
||||
module.exports = __toCommonJS(load_exports);
|
||||
|
||||
// src/rspack/context.ts
|
||||
var import_buffer = require("buffer");
|
||||
var import_webpack_sources = __toESM(require("webpack-sources"));
|
||||
var import_acorn = require("acorn");
|
||||
function createRspackContext(compilation) {
|
||||
return {
|
||||
parse(code, opts = {}) {
|
||||
return import_acorn.Parser.parse(code, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true,
|
||||
...opts
|
||||
});
|
||||
},
|
||||
addWatchFile() {
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
compilation.emitAsset(
|
||||
outFileName,
|
||||
new import_webpack_sources.default.RawSource(
|
||||
// @ts-expect-error types mismatch
|
||||
typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/utils.ts
|
||||
var import_path = require("path");
|
||||
function normalizeAbsolutePath(path) {
|
||||
if ((0, import_path.isAbsolute)(path))
|
||||
return (0, import_path.normalize)(path);
|
||||
else
|
||||
return path;
|
||||
}
|
||||
|
||||
// src/rspack/loaders/load.ts
|
||||
async function load(source, map) {
|
||||
const callback = this.async();
|
||||
const id = this.resource;
|
||||
const { plugin } = this.getOptions();
|
||||
if (!plugin?.load || !id)
|
||||
return callback(null, source, map);
|
||||
if (plugin.loadInclude && !plugin.loadInclude(id))
|
||||
return callback(null, source, map);
|
||||
const context = {
|
||||
error: (error) => this.emitError(typeof error === "string" ? new Error(error) : error),
|
||||
warn: (error) => this.emitWarning(typeof error === "string" ? new Error(error) : error)
|
||||
};
|
||||
const res = await plugin.load.call(
|
||||
Object.assign(
|
||||
this._compilation && createRspackContext(this._compilation),
|
||||
context
|
||||
),
|
||||
normalizeAbsolutePath(id)
|
||||
);
|
||||
if (res == null)
|
||||
callback(null, source, map);
|
||||
else if (typeof res !== "string")
|
||||
callback(null, res.code, res.map ?? map);
|
||||
else
|
||||
callback(null, res, map);
|
||||
}
|
||||
73
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/load.mjs
generated
vendored
Normal file
73
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/load.mjs
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
// src/rspack/context.ts
|
||||
import { Buffer } from "buffer";
|
||||
import sources from "webpack-sources";
|
||||
import { Parser } from "acorn";
|
||||
function createRspackContext(compilation) {
|
||||
return {
|
||||
parse(code, opts = {}) {
|
||||
return Parser.parse(code, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true,
|
||||
...opts
|
||||
});
|
||||
},
|
||||
addWatchFile() {
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
compilation.emitAsset(
|
||||
outFileName,
|
||||
new sources.RawSource(
|
||||
// @ts-expect-error types mismatch
|
||||
typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/utils.ts
|
||||
import { isAbsolute, normalize } from "path";
|
||||
function normalizeAbsolutePath(path) {
|
||||
if (isAbsolute(path))
|
||||
return normalize(path);
|
||||
else
|
||||
return path;
|
||||
}
|
||||
|
||||
// src/rspack/loaders/load.ts
|
||||
async function load(source, map) {
|
||||
const callback = this.async();
|
||||
const id = this.resource;
|
||||
const { plugin } = this.getOptions();
|
||||
if (!plugin?.load || !id)
|
||||
return callback(null, source, map);
|
||||
if (plugin.loadInclude && !plugin.loadInclude(id))
|
||||
return callback(null, source, map);
|
||||
const context = {
|
||||
error: (error) => this.emitError(typeof error === "string" ? new Error(error) : error),
|
||||
warn: (error) => this.emitWarning(typeof error === "string" ? new Error(error) : error)
|
||||
};
|
||||
const res = await plugin.load.call(
|
||||
Object.assign(
|
||||
this._compilation && createRspackContext(this._compilation),
|
||||
context
|
||||
),
|
||||
normalizeAbsolutePath(id)
|
||||
);
|
||||
if (res == null)
|
||||
callback(null, source, map);
|
||||
else if (typeof res !== "string")
|
||||
callback(null, res.code, res.map ?? map);
|
||||
else
|
||||
callback(null, res, map);
|
||||
}
|
||||
export {
|
||||
load as default
|
||||
};
|
||||
5
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/transform.d.mts
generated
vendored
Normal file
5
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/transform.d.mts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { LoaderContext } from '@rspack/core';
|
||||
|
||||
declare function transform(this: LoaderContext, source: string, map: any): Promise<void>;
|
||||
|
||||
export { transform as default };
|
||||
5
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/transform.d.ts
generated
vendored
Normal file
5
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/transform.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { LoaderContext } from '@rspack/core';
|
||||
|
||||
declare function transform(this: LoaderContext, source: string, map: any): Promise<void>;
|
||||
|
||||
export { transform as default };
|
||||
98
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/transform.js
generated
vendored
Normal file
98
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/transform.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/rspack/loaders/transform.ts
|
||||
var transform_exports = {};
|
||||
__export(transform_exports, {
|
||||
default: () => transform
|
||||
});
|
||||
module.exports = __toCommonJS(transform_exports);
|
||||
|
||||
// src/rspack/context.ts
|
||||
var import_buffer = require("buffer");
|
||||
var import_webpack_sources = __toESM(require("webpack-sources"));
|
||||
var import_acorn = require("acorn");
|
||||
function createRspackContext(compilation) {
|
||||
return {
|
||||
parse(code, opts = {}) {
|
||||
return import_acorn.Parser.parse(code, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true,
|
||||
...opts
|
||||
});
|
||||
},
|
||||
addWatchFile() {
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
compilation.emitAsset(
|
||||
outFileName,
|
||||
new import_webpack_sources.default.RawSource(
|
||||
// @ts-expect-error types mismatch
|
||||
typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/rspack/loaders/transform.ts
|
||||
async function transform(source, map) {
|
||||
const callback = this.async();
|
||||
const id = this.resource;
|
||||
const { plugin } = this.getOptions();
|
||||
if (!plugin?.transform)
|
||||
return callback(null, source, map);
|
||||
if (plugin.transformInclude && !plugin.transformInclude(id))
|
||||
return callback(null, source, map);
|
||||
const context = {
|
||||
error: (error) => this.emitError(typeof error === "string" ? new Error(error) : error),
|
||||
warn: (error) => this.emitWarning(typeof error === "string" ? new Error(error) : error)
|
||||
};
|
||||
const res = await plugin.transform.call(
|
||||
Object.assign(
|
||||
this._compilation && createRspackContext(this._compilation),
|
||||
context
|
||||
),
|
||||
source,
|
||||
id
|
||||
);
|
||||
if (res == null)
|
||||
callback(null, source, map);
|
||||
else if (typeof res !== "string")
|
||||
callback(null, res.code, map == null ? map : res.map || map);
|
||||
else
|
||||
callback(null, res, map);
|
||||
}
|
||||
65
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/transform.mjs
generated
vendored
Normal file
65
uni_modules/UniDevTools/node_modules/unplugin/dist/rspack/loaders/transform.mjs
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
// src/rspack/context.ts
|
||||
import { Buffer } from "buffer";
|
||||
import sources from "webpack-sources";
|
||||
import { Parser } from "acorn";
|
||||
function createRspackContext(compilation) {
|
||||
return {
|
||||
parse(code, opts = {}) {
|
||||
return Parser.parse(code, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true,
|
||||
...opts
|
||||
});
|
||||
},
|
||||
addWatchFile() {
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
compilation.emitAsset(
|
||||
outFileName,
|
||||
new sources.RawSource(
|
||||
// @ts-expect-error types mismatch
|
||||
typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/rspack/loaders/transform.ts
|
||||
async function transform(source, map) {
|
||||
const callback = this.async();
|
||||
const id = this.resource;
|
||||
const { plugin } = this.getOptions();
|
||||
if (!plugin?.transform)
|
||||
return callback(null, source, map);
|
||||
if (plugin.transformInclude && !plugin.transformInclude(id))
|
||||
return callback(null, source, map);
|
||||
const context = {
|
||||
error: (error) => this.emitError(typeof error === "string" ? new Error(error) : error),
|
||||
warn: (error) => this.emitWarning(typeof error === "string" ? new Error(error) : error)
|
||||
};
|
||||
const res = await plugin.transform.call(
|
||||
Object.assign(
|
||||
this._compilation && createRspackContext(this._compilation),
|
||||
context
|
||||
),
|
||||
source,
|
||||
id
|
||||
);
|
||||
if (res == null)
|
||||
callback(null, source, map);
|
||||
else if (typeof res !== "string")
|
||||
callback(null, res.code, map == null ? map : res.map || map);
|
||||
else
|
||||
callback(null, res, map);
|
||||
}
|
||||
export {
|
||||
transform as default
|
||||
};
|
||||
5
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/load.d.mts
generated
vendored
Normal file
5
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/load.d.mts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { LoaderContext } from 'webpack';
|
||||
|
||||
declare function load(this: LoaderContext<any>, source: string, map: any): Promise<void>;
|
||||
|
||||
export { load as default };
|
||||
5
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/load.d.ts
generated
vendored
Normal file
5
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/load.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { LoaderContext } from 'webpack';
|
||||
|
||||
declare function load(this: LoaderContext<any>, source: string, map: any): Promise<void>;
|
||||
|
||||
export { load as default };
|
||||
113
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/load.js
generated
vendored
Normal file
113
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/load.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/webpack/loaders/load.ts
|
||||
var load_exports = {};
|
||||
__export(load_exports, {
|
||||
default: () => load
|
||||
});
|
||||
module.exports = __toCommonJS(load_exports);
|
||||
|
||||
// src/webpack/context.ts
|
||||
var import_path = require("path");
|
||||
var import_buffer = require("buffer");
|
||||
var import_webpack_sources = __toESM(require("webpack-sources"));
|
||||
var import_acorn = require("acorn");
|
||||
function createContext(compilation) {
|
||||
return {
|
||||
parse(code, opts = {}) {
|
||||
return import_acorn.Parser.parse(code, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true,
|
||||
...opts
|
||||
});
|
||||
},
|
||||
addWatchFile(id) {
|
||||
(compilation.fileDependencies ?? compilation.compilationDependencies).add(
|
||||
(0, import_path.resolve)(process.cwd(), id)
|
||||
);
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
compilation.emitAsset(
|
||||
outFileName,
|
||||
import_webpack_sources.default ? new import_webpack_sources.default.RawSource(
|
||||
// @ts-expect-error types mismatch
|
||||
typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
|
||||
) : {
|
||||
source: () => emittedFile.source,
|
||||
size: () => emittedFile.source.length
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return Array.from(
|
||||
compilation.fileDependencies ?? compilation.compilationDependencies
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/utils.ts
|
||||
var import_path2 = require("path");
|
||||
function normalizeAbsolutePath(path) {
|
||||
if ((0, import_path2.isAbsolute)(path))
|
||||
return (0, import_path2.normalize)(path);
|
||||
else
|
||||
return path;
|
||||
}
|
||||
|
||||
// src/webpack/loaders/load.ts
|
||||
async function load(source, map) {
|
||||
const callback = this.async();
|
||||
const { unpluginName } = this.query;
|
||||
const plugin = this._compiler?.$unpluginContext[unpluginName];
|
||||
let id = this.resource;
|
||||
if (!plugin?.load || !id)
|
||||
return callback(null, source, map);
|
||||
const context = {
|
||||
error: (error) => this.emitError(typeof error === "string" ? new Error(error) : error),
|
||||
warn: (error) => this.emitWarning(typeof error === "string" ? new Error(error) : error)
|
||||
};
|
||||
if (id.startsWith(plugin.__virtualModulePrefix))
|
||||
id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
|
||||
const res = await plugin.load.call(
|
||||
Object.assign(this._compilation && createContext(this._compilation), context),
|
||||
normalizeAbsolutePath(id)
|
||||
);
|
||||
if (res == null)
|
||||
callback(null, source, map);
|
||||
else if (typeof res !== "string")
|
||||
callback(null, res.code, res.map ?? map);
|
||||
else
|
||||
callback(null, res, map);
|
||||
}
|
||||
80
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/load.mjs
generated
vendored
Normal file
80
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/load.mjs
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
// src/webpack/context.ts
|
||||
import { resolve } from "path";
|
||||
import { Buffer } from "buffer";
|
||||
import sources from "webpack-sources";
|
||||
import { Parser } from "acorn";
|
||||
function createContext(compilation) {
|
||||
return {
|
||||
parse(code, opts = {}) {
|
||||
return Parser.parse(code, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true,
|
||||
...opts
|
||||
});
|
||||
},
|
||||
addWatchFile(id) {
|
||||
(compilation.fileDependencies ?? compilation.compilationDependencies).add(
|
||||
resolve(process.cwd(), id)
|
||||
);
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
compilation.emitAsset(
|
||||
outFileName,
|
||||
sources ? new sources.RawSource(
|
||||
// @ts-expect-error types mismatch
|
||||
typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
|
||||
) : {
|
||||
source: () => emittedFile.source,
|
||||
size: () => emittedFile.source.length
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return Array.from(
|
||||
compilation.fileDependencies ?? compilation.compilationDependencies
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/utils.ts
|
||||
import { isAbsolute, normalize } from "path";
|
||||
function normalizeAbsolutePath(path) {
|
||||
if (isAbsolute(path))
|
||||
return normalize(path);
|
||||
else
|
||||
return path;
|
||||
}
|
||||
|
||||
// src/webpack/loaders/load.ts
|
||||
async function load(source, map) {
|
||||
const callback = this.async();
|
||||
const { unpluginName } = this.query;
|
||||
const plugin = this._compiler?.$unpluginContext[unpluginName];
|
||||
let id = this.resource;
|
||||
if (!plugin?.load || !id)
|
||||
return callback(null, source, map);
|
||||
const context = {
|
||||
error: (error) => this.emitError(typeof error === "string" ? new Error(error) : error),
|
||||
warn: (error) => this.emitWarning(typeof error === "string" ? new Error(error) : error)
|
||||
};
|
||||
if (id.startsWith(plugin.__virtualModulePrefix))
|
||||
id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
|
||||
const res = await plugin.load.call(
|
||||
Object.assign(this._compilation && createContext(this._compilation), context),
|
||||
normalizeAbsolutePath(id)
|
||||
);
|
||||
if (res == null)
|
||||
callback(null, source, map);
|
||||
else if (typeof res !== "string")
|
||||
callback(null, res.code, res.map ?? map);
|
||||
else
|
||||
callback(null, res, map);
|
||||
}
|
||||
export {
|
||||
load as default
|
||||
};
|
||||
7
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/transform.d.mts
generated
vendored
Normal file
7
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/transform.d.mts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { LoaderContext } from 'webpack';
|
||||
|
||||
declare function transform(this: LoaderContext<{
|
||||
unpluginName: string;
|
||||
}>, source: string, map: any): Promise<void>;
|
||||
|
||||
export { transform as default };
|
||||
7
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/transform.d.ts
generated
vendored
Normal file
7
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/transform.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { LoaderContext } from 'webpack';
|
||||
|
||||
declare function transform(this: LoaderContext<{
|
||||
unpluginName: string;
|
||||
}>, source: string, map: any): Promise<void>;
|
||||
|
||||
export { transform as default };
|
||||
104
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/transform.js
generated
vendored
Normal file
104
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/transform.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/webpack/loaders/transform.ts
|
||||
var transform_exports = {};
|
||||
__export(transform_exports, {
|
||||
default: () => transform
|
||||
});
|
||||
module.exports = __toCommonJS(transform_exports);
|
||||
|
||||
// src/webpack/context.ts
|
||||
var import_path = require("path");
|
||||
var import_buffer = require("buffer");
|
||||
var import_webpack_sources = __toESM(require("webpack-sources"));
|
||||
var import_acorn = require("acorn");
|
||||
function createContext(compilation) {
|
||||
return {
|
||||
parse(code, opts = {}) {
|
||||
return import_acorn.Parser.parse(code, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true,
|
||||
...opts
|
||||
});
|
||||
},
|
||||
addWatchFile(id) {
|
||||
(compilation.fileDependencies ?? compilation.compilationDependencies).add(
|
||||
(0, import_path.resolve)(process.cwd(), id)
|
||||
);
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
compilation.emitAsset(
|
||||
outFileName,
|
||||
import_webpack_sources.default ? new import_webpack_sources.default.RawSource(
|
||||
// @ts-expect-error types mismatch
|
||||
typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
|
||||
) : {
|
||||
source: () => emittedFile.source,
|
||||
size: () => emittedFile.source.length
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return Array.from(
|
||||
compilation.fileDependencies ?? compilation.compilationDependencies
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/webpack/loaders/transform.ts
|
||||
async function transform(source, map) {
|
||||
const callback = this.async();
|
||||
let unpluginName;
|
||||
if (typeof this.query === "string") {
|
||||
const query = new URLSearchParams(this.query);
|
||||
unpluginName = query.get("unpluginName");
|
||||
} else {
|
||||
unpluginName = this.query.unpluginName;
|
||||
}
|
||||
const plugin = this._compiler?.$unpluginContext[unpluginName];
|
||||
if (!plugin?.transform)
|
||||
return callback(null, source, map);
|
||||
const context = {
|
||||
error: (error) => this.emitError(typeof error === "string" ? new Error(error) : error),
|
||||
warn: (error) => this.emitWarning(typeof error === "string" ? new Error(error) : error)
|
||||
};
|
||||
const res = await plugin.transform.call(Object.assign(this._compilation && createContext(this._compilation), context), source, this.resource);
|
||||
if (res == null)
|
||||
callback(null, source, map);
|
||||
else if (typeof res !== "string")
|
||||
callback(null, res.code, map == null ? map : res.map || map);
|
||||
else
|
||||
callback(null, res, map);
|
||||
}
|
||||
71
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/transform.mjs
generated
vendored
Normal file
71
uni_modules/UniDevTools/node_modules/unplugin/dist/webpack/loaders/transform.mjs
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// src/webpack/context.ts
|
||||
import { resolve } from "path";
|
||||
import { Buffer } from "buffer";
|
||||
import sources from "webpack-sources";
|
||||
import { Parser } from "acorn";
|
||||
function createContext(compilation) {
|
||||
return {
|
||||
parse(code, opts = {}) {
|
||||
return Parser.parse(code, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true,
|
||||
...opts
|
||||
});
|
||||
},
|
||||
addWatchFile(id) {
|
||||
(compilation.fileDependencies ?? compilation.compilationDependencies).add(
|
||||
resolve(process.cwd(), id)
|
||||
);
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
compilation.emitAsset(
|
||||
outFileName,
|
||||
sources ? new sources.RawSource(
|
||||
// @ts-expect-error types mismatch
|
||||
typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
|
||||
) : {
|
||||
source: () => emittedFile.source,
|
||||
size: () => emittedFile.source.length
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return Array.from(
|
||||
compilation.fileDependencies ?? compilation.compilationDependencies
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/webpack/loaders/transform.ts
|
||||
async function transform(source, map) {
|
||||
const callback = this.async();
|
||||
let unpluginName;
|
||||
if (typeof this.query === "string") {
|
||||
const query = new URLSearchParams(this.query);
|
||||
unpluginName = query.get("unpluginName");
|
||||
} else {
|
||||
unpluginName = this.query.unpluginName;
|
||||
}
|
||||
const plugin = this._compiler?.$unpluginContext[unpluginName];
|
||||
if (!plugin?.transform)
|
||||
return callback(null, source, map);
|
||||
const context = {
|
||||
error: (error) => this.emitError(typeof error === "string" ? new Error(error) : error),
|
||||
warn: (error) => this.emitWarning(typeof error === "string" ? new Error(error) : error)
|
||||
};
|
||||
const res = await plugin.transform.call(Object.assign(this._compilation && createContext(this._compilation), context), source, this.resource);
|
||||
if (res == null)
|
||||
callback(null, source, map);
|
||||
else if (typeof res !== "string")
|
||||
callback(null, res.code, map == null ? map : res.map || map);
|
||||
else
|
||||
callback(null, res, map);
|
||||
}
|
||||
export {
|
||||
transform as default
|
||||
};
|
||||
Reference in New Issue
Block a user