@promoboxx/react-scripts-vite 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/muteWarnings.d.ts +12 -0
- package/dist/cjs/muteWarnings.js +70 -0
- package/dist/cjs/viteConfig.d.ts +2 -1
- package/dist/cjs/viteConfig.js +36 -2
- package/dist/esm/muteWarnings.d.mts +12 -0
- package/dist/esm/muteWarnings.mjs +48 -0
- package/dist/esm/viteConfig.d.mts +2 -1
- package/dist/esm/viteConfig.mjs +36 -2
- package/package.json +10 -9
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mutes Rollup warnings.
|
|
5
|
+
* https://github.com/vitejs/vite/issues/15012#issuecomment-1825035992
|
|
6
|
+
*/
|
|
7
|
+
declare const muteWarnings: (options: {
|
|
8
|
+
warningsToIgnore: string[][];
|
|
9
|
+
debugWarnings?: boolean;
|
|
10
|
+
}) => Plugin;
|
|
11
|
+
|
|
12
|
+
export = muteWarnings;
|
|
@@ -0,0 +1,70 @@
|
|
|
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/muteWarnings.ts
|
|
21
|
+
var muteWarnings_exports = {};
|
|
22
|
+
__export(muteWarnings_exports, {
|
|
23
|
+
default: () => muteWarnings_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(muteWarnings_exports);
|
|
26
|
+
var muteWarnings = (options) => {
|
|
27
|
+
const mutedMessages = /* @__PURE__ */ new Set();
|
|
28
|
+
return {
|
|
29
|
+
name: "mute-warnings",
|
|
30
|
+
enforce: "pre",
|
|
31
|
+
config: (userConfig) => ({
|
|
32
|
+
build: {
|
|
33
|
+
rollupOptions: {
|
|
34
|
+
onwarn(warning, defaultHandler) {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
if (warning.code) {
|
|
37
|
+
if (options.debugWarnings) {
|
|
38
|
+
console.warn(`${warning.code} - ${warning.message}`);
|
|
39
|
+
}
|
|
40
|
+
const muted = options.warningsToIgnore.find(
|
|
41
|
+
([code, message]) => code === warning.code && warning.message.includes(message)
|
|
42
|
+
);
|
|
43
|
+
if (muted) {
|
|
44
|
+
mutedMessages.add(muted.join());
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if ((_b = (_a = userConfig.build) == null ? void 0 : _a.rollupOptions) == null ? void 0 : _b.onwarn) {
|
|
49
|
+
userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
|
|
50
|
+
} else {
|
|
51
|
+
defaultHandler(warning);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
closeBundle() {
|
|
58
|
+
const diff = options.warningsToIgnore.filter(
|
|
59
|
+
(x) => !mutedMessages.has(x.join())
|
|
60
|
+
);
|
|
61
|
+
if (diff.length > 0) {
|
|
62
|
+
this.warn(
|
|
63
|
+
"Some of your muted warnings never appeared during the build process:"
|
|
64
|
+
);
|
|
65
|
+
diff.forEach((m) => this.warn(`- ${m.join(": ")}`));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
var muteWarnings_default = muteWarnings;
|
package/dist/cjs/viteConfig.d.ts
CHANGED
|
@@ -11,8 +11,9 @@ interface ReactScriptsViteOptions {
|
|
|
11
11
|
aliasHq?: false;
|
|
12
12
|
envCompatible?: false | Parameters<typeof envCompatible>[1];
|
|
13
13
|
pwa?: false | Parameters<typeof VitePWA>[0];
|
|
14
|
-
checker
|
|
14
|
+
checker?: false | Parameters<typeof pluginChecker>[0];
|
|
15
15
|
envPrefix?: string;
|
|
16
|
+
splitVendorChunkPlugin?: false;
|
|
16
17
|
}
|
|
17
18
|
declare const pluginOptions: ReactScriptsViteOptions;
|
|
18
19
|
declare const viteConfig: UserConfigFn;
|
package/dist/cjs/viteConfig.js
CHANGED
|
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(viteConfig_exports);
|
|
|
37
37
|
var import_fs = __toESM(require("fs"));
|
|
38
38
|
var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
|
|
39
39
|
var import_alias_hq = __toESM(require("alias-hq"));
|
|
40
|
+
var import_vite = require("vite");
|
|
40
41
|
var import_vite_plugin_checker = __toESM(require("vite-plugin-checker"));
|
|
41
42
|
var import_vite_plugin_environment = __toESM(require("vite-plugin-environment"));
|
|
42
43
|
var import_vite_plugin_pwa = require("vite-plugin-pwa");
|
|
@@ -55,6 +56,37 @@ var pluginOptions = {
|
|
|
55
56
|
},
|
|
56
57
|
react: {
|
|
57
58
|
jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
|
|
59
|
+
},
|
|
60
|
+
svgr: {
|
|
61
|
+
svgrOptions: {
|
|
62
|
+
titleProp: true,
|
|
63
|
+
descProp: true,
|
|
64
|
+
ref: true,
|
|
65
|
+
memo: true,
|
|
66
|
+
// It's not obvious, but these plugins are needed to just be able to pass
|
|
67
|
+
// options to svgo, and they're not really documented in svgr.
|
|
68
|
+
// https://github.com/pd4d10/vite-plugin-svgr/blob/57873c10f9be1484517b90e2dfbe2e23fa62a183/README.md?plain=1#L66-L78
|
|
69
|
+
plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
|
|
70
|
+
svgo: true,
|
|
71
|
+
// Stop svgr from touching dimensions / viewBox / the svgo config.
|
|
72
|
+
dimensions: false,
|
|
73
|
+
svgoConfig: {
|
|
74
|
+
plugins: [
|
|
75
|
+
{
|
|
76
|
+
name: "preset-default",
|
|
77
|
+
params: {
|
|
78
|
+
overrides: {
|
|
79
|
+
// Don't remove viewBox if it exists in the svg.
|
|
80
|
+
removeViewBox: false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
// Finally, remove dimensions, and more importantly, set a viewBox if
|
|
85
|
+
// it doesn't exist.
|
|
86
|
+
"removeDimensions"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
58
90
|
}
|
|
59
91
|
};
|
|
60
92
|
var viteConfig = () => {
|
|
@@ -84,7 +116,8 @@ var viteConfig = () => {
|
|
|
84
116
|
// PWA.
|
|
85
117
|
pluginOptions.pwa === false ? null : (0, import_vite_plugin_pwa.VitePWA)(pluginOptions.pwa),
|
|
86
118
|
// Check for issues.
|
|
87
|
-
process.env.NODE_ENV === "test" || pluginOptions.checker === false ? null : (0, import_vite_plugin_checker.default)(pluginOptions.checker)
|
|
119
|
+
process.env.NODE_ENV === "test" || pluginOptions.checker === false ? null : (0, import_vite_plugin_checker.default)(pluginOptions.checker || {}),
|
|
120
|
+
pluginOptions.splitVendorChunkPlugin === false ? null : (0, import_vite.splitVendorChunkPlugin)()
|
|
88
121
|
],
|
|
89
122
|
server: {
|
|
90
123
|
open: true,
|
|
@@ -98,7 +131,8 @@ var viteConfig = () => {
|
|
|
98
131
|
test: {
|
|
99
132
|
globals: true,
|
|
100
133
|
environment: "jsdom",
|
|
101
|
-
setupFiles: "./src/test/setup.ts"
|
|
134
|
+
setupFiles: "./src/test/setup.ts",
|
|
135
|
+
reporters: "verbose"
|
|
102
136
|
},
|
|
103
137
|
resolve: {
|
|
104
138
|
alias: pluginOptions.aliasHq === false ? {} : import_alias_hq.default.get("rollup")
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mutes Rollup warnings.
|
|
5
|
+
* https://github.com/vitejs/vite/issues/15012#issuecomment-1825035992
|
|
6
|
+
*/
|
|
7
|
+
declare const muteWarnings: (options: {
|
|
8
|
+
warningsToIgnore: string[][];
|
|
9
|
+
debugWarnings?: boolean;
|
|
10
|
+
}) => Plugin;
|
|
11
|
+
|
|
12
|
+
export { muteWarnings as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/muteWarnings.ts
|
|
2
|
+
var muteWarnings = (options) => {
|
|
3
|
+
const mutedMessages = /* @__PURE__ */ new Set();
|
|
4
|
+
return {
|
|
5
|
+
name: "mute-warnings",
|
|
6
|
+
enforce: "pre",
|
|
7
|
+
config: (userConfig) => ({
|
|
8
|
+
build: {
|
|
9
|
+
rollupOptions: {
|
|
10
|
+
onwarn(warning, defaultHandler) {
|
|
11
|
+
if (warning.code) {
|
|
12
|
+
if (options.debugWarnings) {
|
|
13
|
+
console.warn(`${warning.code} - ${warning.message}`);
|
|
14
|
+
}
|
|
15
|
+
const muted = options.warningsToIgnore.find(
|
|
16
|
+
([code, message]) => code === warning.code && warning.message.includes(message)
|
|
17
|
+
);
|
|
18
|
+
if (muted) {
|
|
19
|
+
mutedMessages.add(muted.join());
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (userConfig.build?.rollupOptions?.onwarn) {
|
|
24
|
+
userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
|
|
25
|
+
} else {
|
|
26
|
+
defaultHandler(warning);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
closeBundle() {
|
|
33
|
+
const diff = options.warningsToIgnore.filter(
|
|
34
|
+
(x) => !mutedMessages.has(x.join())
|
|
35
|
+
);
|
|
36
|
+
if (diff.length > 0) {
|
|
37
|
+
this.warn(
|
|
38
|
+
"Some of your muted warnings never appeared during the build process:"
|
|
39
|
+
);
|
|
40
|
+
diff.forEach((m) => this.warn(`- ${m.join(": ")}`));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
var muteWarnings_default = muteWarnings;
|
|
46
|
+
export {
|
|
47
|
+
muteWarnings_default as default
|
|
48
|
+
};
|
|
@@ -11,8 +11,9 @@ interface ReactScriptsViteOptions {
|
|
|
11
11
|
aliasHq?: false;
|
|
12
12
|
envCompatible?: false | Parameters<typeof envCompatible>[1];
|
|
13
13
|
pwa?: false | Parameters<typeof VitePWA>[0];
|
|
14
|
-
checker
|
|
14
|
+
checker?: false | Parameters<typeof pluginChecker>[0];
|
|
15
15
|
envPrefix?: string;
|
|
16
|
+
splitVendorChunkPlugin?: false;
|
|
16
17
|
}
|
|
17
18
|
declare const pluginOptions: ReactScriptsViteOptions;
|
|
18
19
|
declare const viteConfig: UserConfigFn;
|
package/dist/esm/viteConfig.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import react from "@vitejs/plugin-react";
|
|
4
4
|
import aliasHq from "alias-hq";
|
|
5
|
+
import { splitVendorChunkPlugin } from "vite";
|
|
5
6
|
import pluginChecker from "vite-plugin-checker";
|
|
6
7
|
import envCompatible from "vite-plugin-environment";
|
|
7
8
|
import { VitePWA } from "vite-plugin-pwa";
|
|
@@ -20,6 +21,37 @@ var pluginOptions = {
|
|
|
20
21
|
},
|
|
21
22
|
react: {
|
|
22
23
|
jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
|
|
24
|
+
},
|
|
25
|
+
svgr: {
|
|
26
|
+
svgrOptions: {
|
|
27
|
+
titleProp: true,
|
|
28
|
+
descProp: true,
|
|
29
|
+
ref: true,
|
|
30
|
+
memo: true,
|
|
31
|
+
// It's not obvious, but these plugins are needed to just be able to pass
|
|
32
|
+
// options to svgo, and they're not really documented in svgr.
|
|
33
|
+
// https://github.com/pd4d10/vite-plugin-svgr/blob/57873c10f9be1484517b90e2dfbe2e23fa62a183/README.md?plain=1#L66-L78
|
|
34
|
+
plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
|
|
35
|
+
svgo: true,
|
|
36
|
+
// Stop svgr from touching dimensions / viewBox / the svgo config.
|
|
37
|
+
dimensions: false,
|
|
38
|
+
svgoConfig: {
|
|
39
|
+
plugins: [
|
|
40
|
+
{
|
|
41
|
+
name: "preset-default",
|
|
42
|
+
params: {
|
|
43
|
+
overrides: {
|
|
44
|
+
// Don't remove viewBox if it exists in the svg.
|
|
45
|
+
removeViewBox: false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
// Finally, remove dimensions, and more importantly, set a viewBox if
|
|
50
|
+
// it doesn't exist.
|
|
51
|
+
"removeDimensions"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
23
55
|
}
|
|
24
56
|
};
|
|
25
57
|
var viteConfig = () => {
|
|
@@ -49,7 +81,8 @@ var viteConfig = () => {
|
|
|
49
81
|
// PWA.
|
|
50
82
|
pluginOptions.pwa === false ? null : VitePWA(pluginOptions.pwa),
|
|
51
83
|
// Check for issues.
|
|
52
|
-
process.env.NODE_ENV === "test" || pluginOptions.checker === false ? null : pluginChecker(pluginOptions.checker)
|
|
84
|
+
process.env.NODE_ENV === "test" || pluginOptions.checker === false ? null : pluginChecker(pluginOptions.checker || {}),
|
|
85
|
+
pluginOptions.splitVendorChunkPlugin === false ? null : splitVendorChunkPlugin()
|
|
53
86
|
],
|
|
54
87
|
server: {
|
|
55
88
|
open: true,
|
|
@@ -63,7 +96,8 @@ var viteConfig = () => {
|
|
|
63
96
|
test: {
|
|
64
97
|
globals: true,
|
|
65
98
|
environment: "jsdom",
|
|
66
|
-
setupFiles: "./src/test/setup.ts"
|
|
99
|
+
setupFiles: "./src/test/setup.ts",
|
|
100
|
+
reporters: "verbose"
|
|
67
101
|
},
|
|
68
102
|
resolve: {
|
|
69
103
|
alias: pluginOptions.aliasHq === false ? {} : aliasHq.get("rollup")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promoboxx/react-scripts-vite",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -20,10 +20,9 @@
|
|
|
20
20
|
"@promoboxx/eslint-config": "^3.2.0",
|
|
21
21
|
"@types/node": "^20.10.4",
|
|
22
22
|
"concurrently": "^8.2.2",
|
|
23
|
-
"
|
|
24
|
-
"prettier": "^3.1.0",
|
|
23
|
+
"prettier": "^3.1.1",
|
|
25
24
|
"tsup": "^8.0.1",
|
|
26
|
-
"typescript": "^5.3.
|
|
25
|
+
"typescript": "^5.3.3"
|
|
27
26
|
},
|
|
28
27
|
"exports": {
|
|
29
28
|
".": {
|
|
@@ -36,16 +35,18 @@
|
|
|
36
35
|
}
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
|
-
"@
|
|
38
|
+
"@svgr/plugin-jsx": "^8.1.0",
|
|
39
|
+
"@svgr/plugin-svgo": "^8.1.0",
|
|
40
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
40
41
|
"alias-hq": "^6.2.3",
|
|
41
42
|
"eslint": "^8.55.0",
|
|
42
|
-
"jsdom": "^23.0.
|
|
43
|
-
"vite": "^5.0.
|
|
43
|
+
"jsdom": "^23.0.1",
|
|
44
|
+
"vite": "^5.0.9",
|
|
44
45
|
"vite-plugin-checker": "^0.6.2",
|
|
45
46
|
"vite-plugin-environment": "^1.1.3",
|
|
46
|
-
"vite-plugin-pwa": "^0.17.
|
|
47
|
+
"vite-plugin-pwa": "^0.17.4",
|
|
47
48
|
"vite-plugin-svgr": "^4.2.0",
|
|
48
|
-
"vitest": "^0.
|
|
49
|
+
"vitest": "^1.0.4"
|
|
49
50
|
},
|
|
50
51
|
"files": [
|
|
51
52
|
"dist"
|