@datadog/vite-plugin 2.3.3-dev-1 → 2.3.3-dev-2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@datadog/vite-plugin",
3
3
  "packageManager": "yarn@4.0.2",
4
- "version": "2.3.3-dev-1",
4
+ "version": "2.3.3-dev-2",
5
5
  "license": "MIT",
6
6
  "author": "Datadog",
7
7
  "description": "Datadog Vite Plugin",
@@ -16,7 +16,7 @@
16
16
  "repository": {
17
17
  "type": "git",
18
18
  "url": "https://github.com/DataDog/build-plugins",
19
- "directory": "packages/vite-plugin"
19
+ "directory": "packages/published/vite-plugin"
20
20
  },
21
21
  "main": "./dist/src/index.js",
22
22
  "module": "./dist/src/index.mjs",
@@ -53,13 +53,12 @@
53
53
  "dependencies": {
54
54
  "async-retry": "1.3.3",
55
55
  "chalk": "2.3.1",
56
- "fs-extra": "7.0.1",
57
56
  "glob": "11.0.0",
58
57
  "outdent": "0.8.0",
59
58
  "p-queue": "6.6.2",
60
59
  "pretty-bytes": "5.6.0",
61
60
  "simple-git": "3.25.0",
62
- "unplugin": "1.14.1"
61
+ "unplugin": "1.16.0"
63
62
  },
64
63
  "devDependencies": {
65
64
  "@babel/core": "7.24.5",
@@ -1,5 +0,0 @@
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 };
@@ -1,5 +0,0 @@
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 };
@@ -1,128 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/rspack/loaders/load.ts
21
- var load_exports = {};
22
- __export(load_exports, {
23
- default: () => load
24
- });
25
- module.exports = __toCommonJS(load_exports);
26
-
27
- // src/rspack/context.ts
28
- var import_path = require("path");
29
- var import_buffer = require("buffer");
30
- var import_acorn = require("acorn");
31
- function createBuildContext(compiler, compilation, loaderContext) {
32
- return {
33
- getNativeBuildContext() {
34
- return {
35
- framework: "rspack",
36
- compiler,
37
- compilation,
38
- loaderContext
39
- };
40
- },
41
- addWatchFile(file) {
42
- compilation.fileDependencies.add((0, import_path.resolve)(process.cwd(), file));
43
- },
44
- getWatchFiles() {
45
- return Array.from(compilation.fileDependencies);
46
- },
47
- parse(code, opts = {}) {
48
- return import_acorn.Parser.parse(code, {
49
- sourceType: "module",
50
- ecmaVersion: "latest",
51
- locations: true,
52
- ...opts
53
- });
54
- },
55
- emitFile(emittedFile) {
56
- const outFileName = emittedFile.fileName || emittedFile.name;
57
- if (emittedFile.source && outFileName) {
58
- const { sources } = compilation.compiler.webpack;
59
- compilation.emitAsset(
60
- outFileName,
61
- new sources.RawSource(
62
- typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
63
- )
64
- );
65
- }
66
- }
67
- };
68
- }
69
- function createContext(loader) {
70
- return {
71
- error: (error) => loader.emitError(normalizeMessage(error)),
72
- warn: (message) => loader.emitWarning(normalizeMessage(message))
73
- };
74
- }
75
- function normalizeMessage(error) {
76
- const err = new Error(typeof error === "string" ? error : error.message);
77
- if (typeof error === "object") {
78
- err.stack = error.stack;
79
- err.cause = error.meta;
80
- }
81
- return err;
82
- }
83
-
84
- // src/utils.ts
85
- var import_path2 = require("path");
86
- function normalizeAbsolutePath(path) {
87
- if ((0, import_path2.isAbsolute)(path))
88
- return (0, import_path2.normalize)(path);
89
- else
90
- return path;
91
- }
92
-
93
- // src/rspack/utils.ts
94
- var import_path3 = require("path");
95
- function decodeVirtualModuleId(encoded, _plugin) {
96
- return decodeURIComponent((0, import_path3.basename)(encoded));
97
- }
98
- function isVirtualModuleId(encoded, plugin) {
99
- return (0, import_path3.dirname)(encoded) === plugin.__virtualModulePrefix;
100
- }
101
-
102
- // src/rspack/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 (isVirtualModuleId(id, plugin))
112
- id = decodeVirtualModuleId(id, plugin);
113
- const context = createContext(this);
114
- const res = await plugin.load.call(
115
- Object.assign(
116
- {},
117
- this._compilation && createBuildContext(this._compiler, this._compilation, this),
118
- context
119
- ),
120
- normalizeAbsolutePath(id)
121
- );
122
- if (res == null)
123
- callback(null, source, map);
124
- else if (typeof res !== "string")
125
- callback(null, res.code, res.map ?? map);
126
- else
127
- callback(null, res, map);
128
- }
@@ -1,105 +0,0 @@
1
- // src/rspack/context.ts
2
- import { resolve } from "path";
3
- import { Buffer } from "buffer";
4
- import { Parser } from "acorn";
5
- function createBuildContext(compiler, compilation, loaderContext) {
6
- return {
7
- getNativeBuildContext() {
8
- return {
9
- framework: "rspack",
10
- compiler,
11
- compilation,
12
- loaderContext
13
- };
14
- },
15
- addWatchFile(file) {
16
- compilation.fileDependencies.add(resolve(process.cwd(), file));
17
- },
18
- getWatchFiles() {
19
- return Array.from(compilation.fileDependencies);
20
- },
21
- parse(code, opts = {}) {
22
- return Parser.parse(code, {
23
- sourceType: "module",
24
- ecmaVersion: "latest",
25
- locations: true,
26
- ...opts
27
- });
28
- },
29
- emitFile(emittedFile) {
30
- const outFileName = emittedFile.fileName || emittedFile.name;
31
- if (emittedFile.source && outFileName) {
32
- const { sources } = compilation.compiler.webpack;
33
- compilation.emitAsset(
34
- outFileName,
35
- new sources.RawSource(
36
- typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
37
- )
38
- );
39
- }
40
- }
41
- };
42
- }
43
- function createContext(loader) {
44
- return {
45
- error: (error) => loader.emitError(normalizeMessage(error)),
46
- warn: (message) => loader.emitWarning(normalizeMessage(message))
47
- };
48
- }
49
- function normalizeMessage(error) {
50
- const err = new Error(typeof error === "string" ? error : error.message);
51
- if (typeof error === "object") {
52
- err.stack = error.stack;
53
- err.cause = error.meta;
54
- }
55
- return err;
56
- }
57
-
58
- // src/utils.ts
59
- import { isAbsolute, normalize } from "path";
60
- function normalizeAbsolutePath(path) {
61
- if (isAbsolute(path))
62
- return normalize(path);
63
- else
64
- return path;
65
- }
66
-
67
- // src/rspack/utils.ts
68
- import { basename, dirname, resolve as resolve2 } from "path";
69
- function decodeVirtualModuleId(encoded, _plugin) {
70
- return decodeURIComponent(basename(encoded));
71
- }
72
- function isVirtualModuleId(encoded, plugin) {
73
- return dirname(encoded) === plugin.__virtualModulePrefix;
74
- }
75
-
76
- // src/rspack/loaders/load.ts
77
- async function load(source, map) {
78
- var _a;
79
- const callback = this.async();
80
- const { unpluginName } = this.query;
81
- const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
82
- let id = this.resource;
83
- if (!(plugin == null ? void 0 : plugin.load) || !id)
84
- return callback(null, source, map);
85
- if (isVirtualModuleId(id, plugin))
86
- id = decodeVirtualModuleId(id, plugin);
87
- const context = createContext(this);
88
- const res = await plugin.load.call(
89
- Object.assign(
90
- {},
91
- this._compilation && createBuildContext(this._compiler, this._compilation, this),
92
- context
93
- ),
94
- normalizeAbsolutePath(id)
95
- );
96
- if (res == null)
97
- callback(null, source, map);
98
- else if (typeof res !== "string")
99
- callback(null, res.code, res.map ?? map);
100
- else
101
- callback(null, res, map);
102
- }
103
- export {
104
- load as default
105
- };
@@ -1,5 +0,0 @@
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 };
@@ -1,5 +0,0 @@
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 };
@@ -1,114 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/rspack/loaders/transform.ts
21
- var transform_exports = {};
22
- __export(transform_exports, {
23
- default: () => transform
24
- });
25
- module.exports = __toCommonJS(transform_exports);
26
-
27
- // src/rspack/context.ts
28
- var import_path = require("path");
29
- var import_buffer = require("buffer");
30
- var import_acorn = require("acorn");
31
- function createBuildContext(compiler, compilation, loaderContext) {
32
- return {
33
- getNativeBuildContext() {
34
- return {
35
- framework: "rspack",
36
- compiler,
37
- compilation,
38
- loaderContext
39
- };
40
- },
41
- addWatchFile(file) {
42
- compilation.fileDependencies.add((0, import_path.resolve)(process.cwd(), file));
43
- },
44
- getWatchFiles() {
45
- return Array.from(compilation.fileDependencies);
46
- },
47
- parse(code, opts = {}) {
48
- return import_acorn.Parser.parse(code, {
49
- sourceType: "module",
50
- ecmaVersion: "latest",
51
- locations: true,
52
- ...opts
53
- });
54
- },
55
- emitFile(emittedFile) {
56
- const outFileName = emittedFile.fileName || emittedFile.name;
57
- if (emittedFile.source && outFileName) {
58
- const { sources } = compilation.compiler.webpack;
59
- compilation.emitAsset(
60
- outFileName,
61
- new sources.RawSource(
62
- typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
63
- )
64
- );
65
- }
66
- }
67
- };
68
- }
69
- function createContext(loader) {
70
- return {
71
- error: (error) => loader.emitError(normalizeMessage(error)),
72
- warn: (message) => loader.emitWarning(normalizeMessage(message))
73
- };
74
- }
75
- function normalizeMessage(error) {
76
- const err = new Error(typeof error === "string" ? error : error.message);
77
- if (typeof error === "object") {
78
- err.stack = error.stack;
79
- err.cause = error.meta;
80
- }
81
- return err;
82
- }
83
-
84
- // src/rspack/loaders/transform.ts
85
- async function transform(source, map) {
86
- var _a;
87
- const callback = this.async();
88
- let unpluginName;
89
- if (typeof this.query === "string") {
90
- const query = new URLSearchParams(this.query);
91
- unpluginName = query.get("unpluginName");
92
- } else {
93
- unpluginName = this.query.unpluginName;
94
- }
95
- const id = this.resource;
96
- const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
97
- if (!(plugin == null ? void 0 : plugin.transform))
98
- return callback(null, source, map);
99
- const context = createContext(this);
100
- const res = await plugin.transform.call(
101
- Object.assign(
102
- {},
103
- this._compilation && createBuildContext(this._compiler, this._compilation, this),
104
- context
105
- ),
106
- source,
107
- id
108
- );
109
- if (res == null)
110
- callback(null, source, map);
111
- else if (typeof res !== "string")
112
- callback(null, res.code, map == null ? map : res.map || map);
113
- else callback(null, res, map);
114
- }
@@ -1,91 +0,0 @@
1
- // src/rspack/context.ts
2
- import { resolve } from "path";
3
- import { Buffer } from "buffer";
4
- import { Parser } from "acorn";
5
- function createBuildContext(compiler, compilation, loaderContext) {
6
- return {
7
- getNativeBuildContext() {
8
- return {
9
- framework: "rspack",
10
- compiler,
11
- compilation,
12
- loaderContext
13
- };
14
- },
15
- addWatchFile(file) {
16
- compilation.fileDependencies.add(resolve(process.cwd(), file));
17
- },
18
- getWatchFiles() {
19
- return Array.from(compilation.fileDependencies);
20
- },
21
- parse(code, opts = {}) {
22
- return Parser.parse(code, {
23
- sourceType: "module",
24
- ecmaVersion: "latest",
25
- locations: true,
26
- ...opts
27
- });
28
- },
29
- emitFile(emittedFile) {
30
- const outFileName = emittedFile.fileName || emittedFile.name;
31
- if (emittedFile.source && outFileName) {
32
- const { sources } = compilation.compiler.webpack;
33
- compilation.emitAsset(
34
- outFileName,
35
- new sources.RawSource(
36
- typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
37
- )
38
- );
39
- }
40
- }
41
- };
42
- }
43
- function createContext(loader) {
44
- return {
45
- error: (error) => loader.emitError(normalizeMessage(error)),
46
- warn: (message) => loader.emitWarning(normalizeMessage(message))
47
- };
48
- }
49
- function normalizeMessage(error) {
50
- const err = new Error(typeof error === "string" ? error : error.message);
51
- if (typeof error === "object") {
52
- err.stack = error.stack;
53
- err.cause = error.meta;
54
- }
55
- return err;
56
- }
57
-
58
- // src/rspack/loaders/transform.ts
59
- async function transform(source, map) {
60
- var _a;
61
- const callback = this.async();
62
- let unpluginName;
63
- if (typeof this.query === "string") {
64
- const query = new URLSearchParams(this.query);
65
- unpluginName = query.get("unpluginName");
66
- } else {
67
- unpluginName = this.query.unpluginName;
68
- }
69
- const id = this.resource;
70
- const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
71
- if (!(plugin == null ? void 0 : plugin.transform))
72
- return callback(null, source, map);
73
- const context = createContext(this);
74
- const res = await plugin.transform.call(
75
- Object.assign(
76
- {},
77
- this._compilation && createBuildContext(this._compiler, this._compilation, this),
78
- context
79
- ),
80
- source,
81
- id
82
- );
83
- if (res == null)
84
- callback(null, source, map);
85
- else if (typeof res !== "string")
86
- callback(null, res.code, map == null ? map : res.map || map);
87
- else callback(null, res, map);
88
- }
89
- export {
90
- transform as default
91
- };
@@ -1,7 +0,0 @@
1
- import { LoaderContext } from 'webpack';
2
-
3
- declare function load(this: LoaderContext<{
4
- unpluginName: string;
5
- }>, source: string, map: any): Promise<void>;
6
-
7
- export { load as default };
@@ -1,7 +0,0 @@
1
- import { LoaderContext } from 'webpack';
2
-
3
- declare function load(this: LoaderContext<{
4
- unpluginName: string;
5
- }>, source: string, map: any): Promise<void>;
6
-
7
- export { load as default };
@@ -1,147 +0,0 @@
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
- // node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_typescript@5.5.4/node_modules/tsup/assets/cjs_shims.js
38
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
39
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
40
-
41
- // src/webpack/context.ts
42
- var import_path = require("path");
43
- var import_buffer = require("buffer");
44
- var import_process = __toESM(require("process"));
45
- var import_module = require("module");
46
- var import_acorn = require("acorn");
47
- function createBuildContext(options, compiler, compilation, loaderContext) {
48
- const require2 = (0, import_module.createRequire)(importMetaUrl);
49
- const sources = require2("webpack-sources");
50
- return {
51
- parse(code, opts = {}) {
52
- return import_acorn.Parser.parse(code, {
53
- sourceType: "module",
54
- ecmaVersion: "latest",
55
- locations: true,
56
- ...opts
57
- });
58
- },
59
- addWatchFile(id) {
60
- options.addWatchFile((0, import_path.resolve)(import_process.default.cwd(), id));
61
- },
62
- emitFile(emittedFile) {
63
- const outFileName = emittedFile.fileName || emittedFile.name;
64
- if (emittedFile.source && outFileName) {
65
- if (!compilation)
66
- throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");
67
- compilation.emitAsset(
68
- outFileName,
69
- sources ? new sources.RawSource(
70
- // @ts-expect-error types mismatch
71
- typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
72
- ) : {
73
- source: () => emittedFile.source,
74
- size: () => emittedFile.source.length
75
- }
76
- );
77
- }
78
- },
79
- getWatchFiles() {
80
- return options.getWatchFiles();
81
- },
82
- getNativeBuildContext() {
83
- return { framework: "webpack", compiler, compilation, loaderContext };
84
- }
85
- };
86
- }
87
- function createContext(loader) {
88
- return {
89
- error: (error) => loader.emitError(normalizeMessage(error)),
90
- warn: (message) => loader.emitWarning(normalizeMessage(message))
91
- };
92
- }
93
- function normalizeMessage(error) {
94
- const err = new Error(typeof error === "string" ? error : error.message);
95
- if (typeof error === "object") {
96
- err.stack = error.stack;
97
- err.cause = error.meta;
98
- }
99
- return err;
100
- }
101
-
102
- // src/utils.ts
103
- var import_path2 = require("path");
104
- function normalizeAbsolutePath(path) {
105
- if ((0, import_path2.isAbsolute)(path))
106
- return (0, import_path2.normalize)(path);
107
- else
108
- return path;
109
- }
110
- function resolveQuery(query) {
111
- if (typeof query === "string") {
112
- return new URLSearchParams(query).get("unpluginName");
113
- } else {
114
- return query.unpluginName;
115
- }
116
- }
117
-
118
- // src/webpack/loaders/load.ts
119
- async function load(source, map) {
120
- var _a;
121
- const callback = this.async();
122
- const unpluginName = resolveQuery(this.query);
123
- const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
124
- let id = this.resource;
125
- if (!(plugin == null ? void 0 : plugin.load) || !id)
126
- return callback(null, source, map);
127
- if (id.startsWith(plugin.__virtualModulePrefix))
128
- id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
129
- const context = createContext(this);
130
- const res = await plugin.load.call(
131
- Object.assign({}, createBuildContext({
132
- addWatchFile: (file) => {
133
- this.addDependency(file);
134
- },
135
- getWatchFiles: () => {
136
- return this.getDependencies();
137
- }
138
- }, this._compiler, this._compilation, this), context),
139
- normalizeAbsolutePath(id)
140
- );
141
- if (res == null)
142
- callback(null, source, map);
143
- else if (typeof res !== "string")
144
- callback(null, res.code, res.map ?? map);
145
- else
146
- callback(null, res, map);
147
- }