@datadog/esbuild-plugin 2.3.1-dev-0 → 2.3.1-dev-1

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.
@@ -0,0 +1,5 @@
1
+ import { LoaderContext } from '@rspack/core';
2
+
3
+ declare function load(this: LoaderContext, source: string, map: any): Promise<void>;
4
+
5
+ export { load as default };
@@ -0,0 +1,5 @@
1
+ import { LoaderContext } from '@rspack/core';
2
+
3
+ declare function load(this: LoaderContext, source: string, map: any): Promise<void>;
4
+
5
+ export { load as default };
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/rspack/loaders/load.ts
31
+ var load_exports = {};
32
+ __export(load_exports, {
33
+ default: () => load
34
+ });
35
+ module.exports = __toCommonJS(load_exports);
36
+
37
+ // src/rspack/context.ts
38
+ var import_buffer = require("buffer");
39
+ var import_webpack_sources = __toESM(require("webpack-sources"));
40
+ var import_acorn = require("acorn");
41
+ function createBuildContext(compilation) {
42
+ return {
43
+ parse(code, opts = {}) {
44
+ return import_acorn.Parser.parse(code, {
45
+ sourceType: "module",
46
+ ecmaVersion: "latest",
47
+ locations: true,
48
+ ...opts
49
+ });
50
+ },
51
+ addWatchFile() {
52
+ },
53
+ emitFile(emittedFile) {
54
+ const outFileName = emittedFile.fileName || emittedFile.name;
55
+ if (emittedFile.source && outFileName) {
56
+ compilation.emitAsset(
57
+ outFileName,
58
+ new import_webpack_sources.default.RawSource(
59
+ // @ts-expect-error types mismatch
60
+ typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
61
+ )
62
+ );
63
+ }
64
+ },
65
+ getWatchFiles() {
66
+ return [];
67
+ }
68
+ };
69
+ }
70
+ function createContext(loader) {
71
+ return {
72
+ error: (error) => loader.emitError(normalizeMessage(error)),
73
+ warn: (message) => loader.emitWarning(normalizeMessage(message))
74
+ };
75
+ }
76
+ function normalizeMessage(error) {
77
+ const err = new Error(typeof error === "string" ? error : error.message);
78
+ if (typeof error === "object") {
79
+ err.stack = error.stack;
80
+ err.cause = error.meta;
81
+ }
82
+ return err;
83
+ }
84
+
85
+ // src/utils.ts
86
+ var import_path = require("path");
87
+ function normalizeAbsolutePath(path) {
88
+ if ((0, import_path.isAbsolute)(path))
89
+ return (0, import_path.normalize)(path);
90
+ else
91
+ return path;
92
+ }
93
+
94
+ // src/rspack/loaders/load.ts
95
+ async function load(source, map) {
96
+ var _a;
97
+ const callback = this.async();
98
+ const { unpluginName } = this.query;
99
+ const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
100
+ const id = this.resource;
101
+ if (!(plugin == null ? void 0 : plugin.load) || !id)
102
+ return callback(null, source, map);
103
+ if (plugin.loadInclude && !plugin.loadInclude(id))
104
+ return callback(null, source, map);
105
+ const context = createContext(this);
106
+ const res = await plugin.load.call(
107
+ Object.assign(
108
+ {},
109
+ this._compilation && createBuildContext(this._compilation),
110
+ context
111
+ ),
112
+ normalizeAbsolutePath(id)
113
+ );
114
+ if (res == null)
115
+ callback(null, source, map);
116
+ else if (typeof res !== "string")
117
+ callback(null, res.code, res.map ?? map);
118
+ else
119
+ callback(null, res, map);
120
+ }
@@ -0,0 +1,87 @@
1
+ // src/rspack/context.ts
2
+ import { Buffer } from "buffer";
3
+ import sources from "webpack-sources";
4
+ import { Parser } from "acorn";
5
+ function createBuildContext(compilation) {
6
+ return {
7
+ parse(code, opts = {}) {
8
+ return Parser.parse(code, {
9
+ sourceType: "module",
10
+ ecmaVersion: "latest",
11
+ locations: true,
12
+ ...opts
13
+ });
14
+ },
15
+ addWatchFile() {
16
+ },
17
+ emitFile(emittedFile) {
18
+ const outFileName = emittedFile.fileName || emittedFile.name;
19
+ if (emittedFile.source && outFileName) {
20
+ compilation.emitAsset(
21
+ outFileName,
22
+ new sources.RawSource(
23
+ // @ts-expect-error types mismatch
24
+ typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
25
+ )
26
+ );
27
+ }
28
+ },
29
+ getWatchFiles() {
30
+ return [];
31
+ }
32
+ };
33
+ }
34
+ function createContext(loader) {
35
+ return {
36
+ error: (error) => loader.emitError(normalizeMessage(error)),
37
+ warn: (message) => loader.emitWarning(normalizeMessage(message))
38
+ };
39
+ }
40
+ function normalizeMessage(error) {
41
+ const err = new Error(typeof error === "string" ? error : error.message);
42
+ if (typeof error === "object") {
43
+ err.stack = error.stack;
44
+ err.cause = error.meta;
45
+ }
46
+ return err;
47
+ }
48
+
49
+ // src/utils.ts
50
+ import { isAbsolute, normalize } from "path";
51
+ function normalizeAbsolutePath(path) {
52
+ if (isAbsolute(path))
53
+ return normalize(path);
54
+ else
55
+ return path;
56
+ }
57
+
58
+ // src/rspack/loaders/load.ts
59
+ async function load(source, map) {
60
+ var _a;
61
+ const callback = this.async();
62
+ const { unpluginName } = this.query;
63
+ const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
64
+ const id = this.resource;
65
+ if (!(plugin == null ? void 0 : plugin.load) || !id)
66
+ return callback(null, source, map);
67
+ if (plugin.loadInclude && !plugin.loadInclude(id))
68
+ return callback(null, source, map);
69
+ const context = createContext(this);
70
+ const res = await plugin.load.call(
71
+ Object.assign(
72
+ {},
73
+ this._compilation && createBuildContext(this._compilation),
74
+ context
75
+ ),
76
+ normalizeAbsolutePath(id)
77
+ );
78
+ if (res == null)
79
+ callback(null, source, map);
80
+ else if (typeof res !== "string")
81
+ callback(null, res.code, res.map ?? map);
82
+ else
83
+ callback(null, res, map);
84
+ }
85
+ export {
86
+ load as default
87
+ };
@@ -0,0 +1,5 @@
1
+ import { LoaderContext } from '@rspack/core';
2
+
3
+ declare function transform(this: LoaderContext, source: string, map: any): Promise<void>;
4
+
5
+ export { transform as default };
@@ -0,0 +1,5 @@
1
+ import { LoaderContext } from '@rspack/core';
2
+
3
+ declare function transform(this: LoaderContext, source: string, map: any): Promise<void>;
4
+
5
+ export { transform as default };
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/rspack/loaders/transform.ts
31
+ var transform_exports = {};
32
+ __export(transform_exports, {
33
+ default: () => transform
34
+ });
35
+ module.exports = __toCommonJS(transform_exports);
36
+
37
+ // src/rspack/context.ts
38
+ var import_buffer = require("buffer");
39
+ var import_webpack_sources = __toESM(require("webpack-sources"));
40
+ var import_acorn = require("acorn");
41
+ function createBuildContext(compilation) {
42
+ return {
43
+ parse(code, opts = {}) {
44
+ return import_acorn.Parser.parse(code, {
45
+ sourceType: "module",
46
+ ecmaVersion: "latest",
47
+ locations: true,
48
+ ...opts
49
+ });
50
+ },
51
+ addWatchFile() {
52
+ },
53
+ emitFile(emittedFile) {
54
+ const outFileName = emittedFile.fileName || emittedFile.name;
55
+ if (emittedFile.source && outFileName) {
56
+ compilation.emitAsset(
57
+ outFileName,
58
+ new import_webpack_sources.default.RawSource(
59
+ // @ts-expect-error types mismatch
60
+ typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
61
+ )
62
+ );
63
+ }
64
+ },
65
+ getWatchFiles() {
66
+ return [];
67
+ }
68
+ };
69
+ }
70
+ function createContext(loader) {
71
+ return {
72
+ error: (error) => loader.emitError(normalizeMessage(error)),
73
+ warn: (message) => loader.emitWarning(normalizeMessage(message))
74
+ };
75
+ }
76
+ function normalizeMessage(error) {
77
+ const err = new Error(typeof error === "string" ? error : error.message);
78
+ if (typeof error === "object") {
79
+ err.stack = error.stack;
80
+ err.cause = error.meta;
81
+ }
82
+ return err;
83
+ }
84
+
85
+ // src/rspack/loaders/transform.ts
86
+ async function transform(source, map) {
87
+ var _a;
88
+ const callback = this.async();
89
+ let unpluginName;
90
+ if (typeof this.query === "string") {
91
+ const query = new URLSearchParams(this.query);
92
+ unpluginName = query.get("unpluginName");
93
+ } else {
94
+ unpluginName = this.query.unpluginName;
95
+ }
96
+ const id = this.resource;
97
+ const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
98
+ if (!(plugin == null ? void 0 : plugin.transform))
99
+ return callback(null, source, map);
100
+ const context = createContext(this);
101
+ const res = await plugin.transform.call(
102
+ Object.assign(
103
+ {},
104
+ this._compilation && createBuildContext(this._compilation),
105
+ context
106
+ ),
107
+ source,
108
+ id
109
+ );
110
+ if (res == null)
111
+ callback(null, source, map);
112
+ else if (typeof res !== "string")
113
+ callback(null, res.code, map == null ? map : res.map || map);
114
+ else
115
+ callback(null, res, map);
116
+ }
@@ -0,0 +1,83 @@
1
+ // src/rspack/context.ts
2
+ import { Buffer } from "buffer";
3
+ import sources from "webpack-sources";
4
+ import { Parser } from "acorn";
5
+ function createBuildContext(compilation) {
6
+ return {
7
+ parse(code, opts = {}) {
8
+ return Parser.parse(code, {
9
+ sourceType: "module",
10
+ ecmaVersion: "latest",
11
+ locations: true,
12
+ ...opts
13
+ });
14
+ },
15
+ addWatchFile() {
16
+ },
17
+ emitFile(emittedFile) {
18
+ const outFileName = emittedFile.fileName || emittedFile.name;
19
+ if (emittedFile.source && outFileName) {
20
+ compilation.emitAsset(
21
+ outFileName,
22
+ new sources.RawSource(
23
+ // @ts-expect-error types mismatch
24
+ typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
25
+ )
26
+ );
27
+ }
28
+ },
29
+ getWatchFiles() {
30
+ return [];
31
+ }
32
+ };
33
+ }
34
+ function createContext(loader) {
35
+ return {
36
+ error: (error) => loader.emitError(normalizeMessage(error)),
37
+ warn: (message) => loader.emitWarning(normalizeMessage(message))
38
+ };
39
+ }
40
+ function normalizeMessage(error) {
41
+ const err = new Error(typeof error === "string" ? error : error.message);
42
+ if (typeof error === "object") {
43
+ err.stack = error.stack;
44
+ err.cause = error.meta;
45
+ }
46
+ return err;
47
+ }
48
+
49
+ // src/rspack/loaders/transform.ts
50
+ async function transform(source, map) {
51
+ var _a;
52
+ const callback = this.async();
53
+ let unpluginName;
54
+ if (typeof this.query === "string") {
55
+ const query = new URLSearchParams(this.query);
56
+ unpluginName = query.get("unpluginName");
57
+ } else {
58
+ unpluginName = this.query.unpluginName;
59
+ }
60
+ const id = this.resource;
61
+ const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
62
+ if (!(plugin == null ? void 0 : plugin.transform))
63
+ return callback(null, source, map);
64
+ const context = createContext(this);
65
+ const res = await plugin.transform.call(
66
+ Object.assign(
67
+ {},
68
+ this._compilation && createBuildContext(this._compilation),
69
+ context
70
+ ),
71
+ source,
72
+ id
73
+ );
74
+ if (res == null)
75
+ callback(null, source, map);
76
+ else if (typeof res !== "string")
77
+ callback(null, res.code, map == null ? map : res.map || map);
78
+ else
79
+ callback(null, res, map);
80
+ }
81
+ export {
82
+ transform as default
83
+ };
@@ -0,0 +1,5 @@
1
+ import { LoaderContext } from 'webpack';
2
+
3
+ declare function load(this: LoaderContext<any>, source: string, map: any): Promise<void>;
4
+
5
+ export { load as default };
@@ -0,0 +1,5 @@
1
+ import { LoaderContext } from 'webpack';
2
+
3
+ declare function load(this: LoaderContext<any>, source: string, map: any): Promise<void>;
4
+
5
+ export { load as default };
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/webpack/loaders/load.ts
31
+ var load_exports = {};
32
+ __export(load_exports, {
33
+ default: () => load
34
+ });
35
+ module.exports = __toCommonJS(load_exports);
36
+
37
+ // src/webpack/context.ts
38
+ var import_path = require("path");
39
+ var import_buffer = require("buffer");
40
+ var import_process = __toESM(require("process"));
41
+ var import_webpack_sources = __toESM(require("webpack-sources"));
42
+ var import_acorn = require("acorn");
43
+ function createBuildContext(options, compilation) {
44
+ return {
45
+ parse(code, opts = {}) {
46
+ return import_acorn.Parser.parse(code, {
47
+ sourceType: "module",
48
+ ecmaVersion: "latest",
49
+ locations: true,
50
+ ...opts
51
+ });
52
+ },
53
+ addWatchFile(id) {
54
+ options.addWatchFile((0, import_path.resolve)(import_process.default.cwd(), id));
55
+ },
56
+ emitFile(emittedFile) {
57
+ const outFileName = emittedFile.fileName || emittedFile.name;
58
+ if (emittedFile.source && outFileName) {
59
+ if (!compilation)
60
+ throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");
61
+ compilation.emitAsset(
62
+ outFileName,
63
+ import_webpack_sources.default ? new import_webpack_sources.default.RawSource(
64
+ // @ts-expect-error types mismatch
65
+ typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
66
+ ) : {
67
+ source: () => emittedFile.source,
68
+ size: () => emittedFile.source.length
69
+ }
70
+ );
71
+ }
72
+ },
73
+ getWatchFiles() {
74
+ return options.getWatchFiles();
75
+ }
76
+ };
77
+ }
78
+ function createContext(loader) {
79
+ return {
80
+ error: (error) => loader.emitError(normalizeMessage(error)),
81
+ warn: (message) => loader.emitWarning(normalizeMessage(message))
82
+ };
83
+ }
84
+ function normalizeMessage(error) {
85
+ const err = new Error(typeof error === "string" ? error : error.message);
86
+ if (typeof error === "object") {
87
+ err.stack = error.stack;
88
+ err.cause = error.meta;
89
+ }
90
+ return err;
91
+ }
92
+
93
+ // src/utils.ts
94
+ var import_path2 = require("path");
95
+ function normalizeAbsolutePath(path) {
96
+ if ((0, import_path2.isAbsolute)(path))
97
+ return (0, import_path2.normalize)(path);
98
+ else
99
+ return path;
100
+ }
101
+
102
+ // src/webpack/loaders/load.ts
103
+ async function load(source, map) {
104
+ var _a;
105
+ const callback = this.async();
106
+ const { unpluginName } = this.query;
107
+ const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
108
+ let id = this.resource;
109
+ if (!(plugin == null ? void 0 : plugin.load) || !id)
110
+ return callback(null, source, map);
111
+ if (id.startsWith(plugin.__virtualModulePrefix))
112
+ id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
113
+ const context = createContext(this);
114
+ const res = await plugin.load.call(
115
+ { ...createBuildContext({
116
+ addWatchFile: (file) => {
117
+ this.addDependency(file);
118
+ },
119
+ getWatchFiles: () => {
120
+ return this.getDependencies();
121
+ }
122
+ }, this._compilation), ...context },
123
+ normalizeAbsolutePath(id)
124
+ );
125
+ if (res == null)
126
+ callback(null, source, map);
127
+ else if (typeof res !== "string")
128
+ callback(null, res.code, res.map ?? map);
129
+ else
130
+ callback(null, res, map);
131
+ }
@@ -0,0 +1,98 @@
1
+ // src/webpack/context.ts
2
+ import { resolve } from "path";
3
+ import { Buffer } from "buffer";
4
+ import process from "process";
5
+ import sources from "webpack-sources";
6
+ import { Parser } from "acorn";
7
+ function createBuildContext(options, compilation) {
8
+ return {
9
+ parse(code, opts = {}) {
10
+ return Parser.parse(code, {
11
+ sourceType: "module",
12
+ ecmaVersion: "latest",
13
+ locations: true,
14
+ ...opts
15
+ });
16
+ },
17
+ addWatchFile(id) {
18
+ options.addWatchFile(resolve(process.cwd(), id));
19
+ },
20
+ emitFile(emittedFile) {
21
+ const outFileName = emittedFile.fileName || emittedFile.name;
22
+ if (emittedFile.source && outFileName) {
23
+ if (!compilation)
24
+ throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");
25
+ compilation.emitAsset(
26
+ outFileName,
27
+ sources ? new sources.RawSource(
28
+ // @ts-expect-error types mismatch
29
+ typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
30
+ ) : {
31
+ source: () => emittedFile.source,
32
+ size: () => emittedFile.source.length
33
+ }
34
+ );
35
+ }
36
+ },
37
+ getWatchFiles() {
38
+ return options.getWatchFiles();
39
+ }
40
+ };
41
+ }
42
+ function createContext(loader) {
43
+ return {
44
+ error: (error) => loader.emitError(normalizeMessage(error)),
45
+ warn: (message) => loader.emitWarning(normalizeMessage(message))
46
+ };
47
+ }
48
+ function normalizeMessage(error) {
49
+ const err = new Error(typeof error === "string" ? error : error.message);
50
+ if (typeof error === "object") {
51
+ err.stack = error.stack;
52
+ err.cause = error.meta;
53
+ }
54
+ return err;
55
+ }
56
+
57
+ // src/utils.ts
58
+ import { isAbsolute, normalize } from "path";
59
+ function normalizeAbsolutePath(path) {
60
+ if (isAbsolute(path))
61
+ return normalize(path);
62
+ else
63
+ return path;
64
+ }
65
+
66
+ // src/webpack/loaders/load.ts
67
+ async function load(source, map) {
68
+ var _a;
69
+ const callback = this.async();
70
+ const { unpluginName } = this.query;
71
+ const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
72
+ let id = this.resource;
73
+ if (!(plugin == null ? void 0 : plugin.load) || !id)
74
+ return callback(null, source, map);
75
+ if (id.startsWith(plugin.__virtualModulePrefix))
76
+ id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
77
+ const context = createContext(this);
78
+ const res = await plugin.load.call(
79
+ { ...createBuildContext({
80
+ addWatchFile: (file) => {
81
+ this.addDependency(file);
82
+ },
83
+ getWatchFiles: () => {
84
+ return this.getDependencies();
85
+ }
86
+ }, this._compilation), ...context },
87
+ normalizeAbsolutePath(id)
88
+ );
89
+ if (res == null)
90
+ callback(null, source, map);
91
+ else if (typeof res !== "string")
92
+ callback(null, res.code, res.map ?? map);
93
+ else
94
+ callback(null, res, map);
95
+ }
96
+ export {
97
+ load as default
98
+ };
@@ -0,0 +1,7 @@
1
+ import { LoaderContext } from 'webpack';
2
+
3
+ declare function transform(this: LoaderContext<{
4
+ unpluginName: string;
5
+ }>, source: string, map: any): Promise<void>;
6
+
7
+ export { transform as default };
@@ -0,0 +1,7 @@
1
+ import { LoaderContext } from 'webpack';
2
+
3
+ declare function transform(this: LoaderContext<{
4
+ unpluginName: string;
5
+ }>, source: string, map: any): Promise<void>;
6
+
7
+ export { transform as default };