@uni_toolkit/unplugin-json-optimization 0.0.10-alpha.1762396524408
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/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/chunk-EUN6NT5L.js +44 -0
- package/dist/index.cjs +79 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +10 -0
- package/dist/types.cjs +18 -0
- package/dist/types.d.cts +8 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.js +0 -0
- package/dist/vite.cjs +76 -0
- package/dist/vite.d.cts +7 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.js +10 -0
- package/dist/webpack.cjs +76 -0
- package/dist/webpack.d.cts +7 -0
- package/dist/webpack.d.ts +7 -0
- package/dist/webpack.js +10 -0
- package/package.json +92 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 chouchouji
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# @uni_toolkit/unplugin-json-optimization
|
|
2
|
+
|
|
3
|
+
一个用于分包优化 JSON 文件生成的 unplugin 插件,支持 Vite 和 Webpack。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 🗜️ **自动优化产物** - 自动优化分包 JSON 文件的生成
|
|
8
|
+
- 🔧 **多构建工具支持** - 支持 Vite、Webpack 等构建工具
|
|
9
|
+
- ⚡ **零配置** - 开箱即用
|
|
10
|
+
- 🎯 **精确匹配** - 只处理 `.json` 文件,不影响其他资源
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# npm
|
|
16
|
+
npm install @uni_toolkit/unplugin-json-optimization -D
|
|
17
|
+
|
|
18
|
+
# yarn
|
|
19
|
+
yarn add @uni_toolkit/unplugin-json-optimization -D
|
|
20
|
+
|
|
21
|
+
# pnpm
|
|
22
|
+
pnpm add @uni_toolkit/unplugin-json-optimization -D
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 使用方法
|
|
26
|
+
|
|
27
|
+
### Vite
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// vite.config.js
|
|
31
|
+
import { defineConfig } from 'vite'
|
|
32
|
+
import uni from "@dcloudio/vite-plugin-uni"
|
|
33
|
+
import jsonOptimization from '@uni_toolkit/unplugin-json-optimization/vite'
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
plugins: [
|
|
37
|
+
uni(),
|
|
38
|
+
jsonOptimization(),
|
|
39
|
+
],
|
|
40
|
+
})
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 配置选项
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
interface ComponentConfigPluginOptions {
|
|
47
|
+
include?: FilterPattern; // 包含的文件模式,默认: ["**/*.{vue,nvue,uvue}"]
|
|
48
|
+
exclude?: FilterPattern; // 排除的文件模式,默认: []
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
[MIT](/LICENSE)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { createUnplugin } from "unplugin";
|
|
3
|
+
import { createFilter } from "@rollup/pluginutils";
|
|
4
|
+
import path from "path";
|
|
5
|
+
var unpluginFactory = (options = {
|
|
6
|
+
includes: ["**/*.json"],
|
|
7
|
+
excludes: ["pages.json", "**/uni_modules/*.json"]
|
|
8
|
+
}) => {
|
|
9
|
+
const jsonFiles = /* @__PURE__ */ new Set();
|
|
10
|
+
const inputDir = process.env.UNI_INPUT_DIR;
|
|
11
|
+
return {
|
|
12
|
+
name: "unplugin-json-optimization",
|
|
13
|
+
enforce: "post",
|
|
14
|
+
load(id) {
|
|
15
|
+
if (!id.endsWith(".json") || !createFilter(options.includes, options.excludes)(id)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
if (!jsonFiles.has(id)) {
|
|
19
|
+
jsonFiles.add(id);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
generateBundle(_, bundle) {
|
|
23
|
+
for (const [, chunk] of Object.entries(bundle)) {
|
|
24
|
+
if (chunk.type !== "chunk" || !chunk.moduleIds) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const id = chunk.moduleIds.find((id2) => jsonFiles.has(id2));
|
|
28
|
+
if (id && !id.includes("/")) {
|
|
29
|
+
const relativePath = path.relative(inputDir, id);
|
|
30
|
+
const { dir, name } = path.parse(relativePath);
|
|
31
|
+
chunk.fileName = `${path.join(dir, name)}.js`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
38
|
+
var src_default = unplugin;
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
unpluginFactory,
|
|
42
|
+
unplugin,
|
|
43
|
+
src_default
|
|
44
|
+
};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
default: () => src_default,
|
|
34
|
+
unplugin: () => unplugin,
|
|
35
|
+
unpluginFactory: () => unpluginFactory
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(src_exports);
|
|
38
|
+
var import_unplugin = require("unplugin");
|
|
39
|
+
var import_pluginutils = require("@rollup/pluginutils");
|
|
40
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
41
|
+
var unpluginFactory = (options = {
|
|
42
|
+
includes: ["**/*.json"],
|
|
43
|
+
excludes: ["pages.json", "**/uni_modules/*.json"]
|
|
44
|
+
}) => {
|
|
45
|
+
const jsonFiles = /* @__PURE__ */ new Set();
|
|
46
|
+
const inputDir = process.env.UNI_INPUT_DIR;
|
|
47
|
+
return {
|
|
48
|
+
name: "unplugin-json-optimization",
|
|
49
|
+
enforce: "post",
|
|
50
|
+
load(id) {
|
|
51
|
+
if (!id.endsWith(".json") || !(0, import_pluginutils.createFilter)(options.includes, options.excludes)(id)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (!jsonFiles.has(id)) {
|
|
55
|
+
jsonFiles.add(id);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
generateBundle(_, bundle) {
|
|
59
|
+
for (const [, chunk] of Object.entries(bundle)) {
|
|
60
|
+
if (chunk.type !== "chunk" || !chunk.moduleIds) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const id = chunk.moduleIds.find((id2) => jsonFiles.has(id2));
|
|
64
|
+
if (id && !id.includes("/")) {
|
|
65
|
+
const relativePath = import_node_path.default.relative(inputDir, id);
|
|
66
|
+
const { dir, name } = import_node_path.default.parse(relativePath);
|
|
67
|
+
chunk.fileName = `${import_node_path.default.join(dir, name)}.js`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
var unplugin = /* @__PURE__ */ (0, import_unplugin.createUnplugin)(unpluginFactory);
|
|
74
|
+
var src_default = unplugin;
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
unplugin,
|
|
78
|
+
unpluginFactory
|
|
79
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _unplugin from 'unplugin';
|
|
2
|
+
import { UnpluginFactory } from 'unplugin';
|
|
3
|
+
import { Options } from './types.cjs';
|
|
4
|
+
import '@rollup/pluginutils';
|
|
5
|
+
|
|
6
|
+
declare const unpluginFactory: UnpluginFactory<Options | undefined>;
|
|
7
|
+
declare const unplugin: _unplugin.UnpluginInstance<Options | undefined, boolean>;
|
|
8
|
+
|
|
9
|
+
export { unplugin as default, unplugin, unpluginFactory };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _unplugin from 'unplugin';
|
|
2
|
+
import { UnpluginFactory } from 'unplugin';
|
|
3
|
+
import { Options } from './types.js';
|
|
4
|
+
import '@rollup/pluginutils';
|
|
5
|
+
|
|
6
|
+
declare const unpluginFactory: UnpluginFactory<Options | undefined>;
|
|
7
|
+
declare const unplugin: _unplugin.UnpluginInstance<Options | undefined, boolean>;
|
|
8
|
+
|
|
9
|
+
export { unplugin as default, unplugin, unpluginFactory };
|
package/dist/index.js
ADDED
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/types.d.cts
ADDED
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
File without changes
|
package/dist/vite.cjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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/vite.ts
|
|
31
|
+
var vite_exports = {};
|
|
32
|
+
__export(vite_exports, {
|
|
33
|
+
default: () => vite_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(vite_exports);
|
|
36
|
+
var import_unplugin2 = require("unplugin");
|
|
37
|
+
|
|
38
|
+
// src/index.ts
|
|
39
|
+
var import_unplugin = require("unplugin");
|
|
40
|
+
var import_pluginutils = require("@rollup/pluginutils");
|
|
41
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
42
|
+
var unpluginFactory = (options = {
|
|
43
|
+
includes: ["**/*.json"],
|
|
44
|
+
excludes: ["pages.json", "**/uni_modules/*.json"]
|
|
45
|
+
}) => {
|
|
46
|
+
const jsonFiles = /* @__PURE__ */ new Set();
|
|
47
|
+
const inputDir = process.env.UNI_INPUT_DIR;
|
|
48
|
+
return {
|
|
49
|
+
name: "unplugin-json-optimization",
|
|
50
|
+
enforce: "post",
|
|
51
|
+
load(id) {
|
|
52
|
+
if (!id.endsWith(".json") || !(0, import_pluginutils.createFilter)(options.includes, options.excludes)(id)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (!jsonFiles.has(id)) {
|
|
56
|
+
jsonFiles.add(id);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
generateBundle(_, bundle) {
|
|
60
|
+
for (const [, chunk] of Object.entries(bundle)) {
|
|
61
|
+
if (chunk.type !== "chunk" || !chunk.moduleIds) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const id = chunk.moduleIds.find((id2) => jsonFiles.has(id2));
|
|
65
|
+
if (id && !id.includes("/")) {
|
|
66
|
+
const relativePath = import_node_path.default.relative(inputDir, id);
|
|
67
|
+
const { dir, name } = import_node_path.default.parse(relativePath);
|
|
68
|
+
chunk.fileName = `${import_node_path.default.join(dir, name)}.js`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/vite.ts
|
|
76
|
+
var vite_default = (0, import_unplugin2.createVitePlugin)(unpluginFactory);
|
package/dist/vite.d.cts
ADDED
package/dist/vite.d.ts
ADDED
package/dist/vite.js
ADDED
package/dist/webpack.cjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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.ts
|
|
31
|
+
var webpack_exports = {};
|
|
32
|
+
__export(webpack_exports, {
|
|
33
|
+
default: () => webpack_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(webpack_exports);
|
|
36
|
+
var import_unplugin2 = require("unplugin");
|
|
37
|
+
|
|
38
|
+
// src/index.ts
|
|
39
|
+
var import_unplugin = require("unplugin");
|
|
40
|
+
var import_pluginutils = require("@rollup/pluginutils");
|
|
41
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
42
|
+
var unpluginFactory = (options = {
|
|
43
|
+
includes: ["**/*.json"],
|
|
44
|
+
excludes: ["pages.json", "**/uni_modules/*.json"]
|
|
45
|
+
}) => {
|
|
46
|
+
const jsonFiles = /* @__PURE__ */ new Set();
|
|
47
|
+
const inputDir = process.env.UNI_INPUT_DIR;
|
|
48
|
+
return {
|
|
49
|
+
name: "unplugin-json-optimization",
|
|
50
|
+
enforce: "post",
|
|
51
|
+
load(id) {
|
|
52
|
+
if (!id.endsWith(".json") || !(0, import_pluginutils.createFilter)(options.includes, options.excludes)(id)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (!jsonFiles.has(id)) {
|
|
56
|
+
jsonFiles.add(id);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
generateBundle(_, bundle) {
|
|
60
|
+
for (const [, chunk] of Object.entries(bundle)) {
|
|
61
|
+
if (chunk.type !== "chunk" || !chunk.moduleIds) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const id = chunk.moduleIds.find((id2) => jsonFiles.has(id2));
|
|
65
|
+
if (id && !id.includes("/")) {
|
|
66
|
+
const relativePath = import_node_path.default.relative(inputDir, id);
|
|
67
|
+
const { dir, name } = import_node_path.default.parse(relativePath);
|
|
68
|
+
chunk.fileName = `${import_node_path.default.join(dir, name)}.js`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/webpack.ts
|
|
76
|
+
var webpack_default = (0, import_unplugin2.createWebpackPlugin)(unpluginFactory);
|
package/dist/webpack.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uni_toolkit/unplugin-json-optimization",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.10-alpha.1762396524408",
|
|
5
|
+
"description": "A plugin to optimize json files generation",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/uni-toolkit/uni-toolkit/tree/main/packages/unplugin-json-optimization",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/uni-toolkit/uni-toolkit.git",
|
|
11
|
+
"directory": "packages/unplugin-json-optimization"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/uni-toolkit/uni-toolkit/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"unplugin",
|
|
21
|
+
"vite",
|
|
22
|
+
"webpack",
|
|
23
|
+
"transform",
|
|
24
|
+
"json",
|
|
25
|
+
"optimization"
|
|
26
|
+
],
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"require": "./dist/index.cjs",
|
|
31
|
+
"types": "./dist/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./types": {
|
|
34
|
+
"import": "./dist/types.js",
|
|
35
|
+
"require": "./dist/types.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./vite": {
|
|
38
|
+
"import": "./dist/vite.js",
|
|
39
|
+
"require": "./dist/vite.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./webpack": {
|
|
42
|
+
"import": "./dist/webpack.js",
|
|
43
|
+
"require": "./dist/webpack.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"main": "./dist/index.cjs",
|
|
48
|
+
"module": "./dist/index.js",
|
|
49
|
+
"types": "./dist/index.d.ts",
|
|
50
|
+
"typesVersions": {
|
|
51
|
+
"*": {
|
|
52
|
+
"*": [
|
|
53
|
+
"./dist/*",
|
|
54
|
+
"./*"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist"
|
|
60
|
+
],
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"vite": ">=3",
|
|
63
|
+
"webpack": "^4 || ^5"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"vite": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"webpack": {
|
|
70
|
+
"optional": true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@rollup/pluginutils": "^4.2.0",
|
|
75
|
+
"unplugin": "^2.3.4"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@types/node": "^22.15.21",
|
|
79
|
+
"nodemon": "^3.1.10",
|
|
80
|
+
"rollup": "^4.41.0",
|
|
81
|
+
"tsup": "7.2.0",
|
|
82
|
+
"tsx": "^4.19.4",
|
|
83
|
+
"typescript": "^5.8.3",
|
|
84
|
+
"vite": "^6.3.5",
|
|
85
|
+
"webpack": "^5.99.9"
|
|
86
|
+
},
|
|
87
|
+
"scripts": {
|
|
88
|
+
"build": "tsup",
|
|
89
|
+
"dev": "tsup --watch",
|
|
90
|
+
"start": "tsx src/index.ts"
|
|
91
|
+
}
|
|
92
|
+
}
|