@unpackjs/core 1.7.5 → 1.7.7
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/compiled/css-loader/index.js +180 -178
- package/compiled/less-loader/index.js +11 -11
- package/compiled/line-diff/index.js +4 -4
- package/compiled/line-diff/license +1 -1
- package/compiled/line-diff/package.json +1 -1
- package/compiled/portfinder/index.js +37 -37
- package/compiled/postcss-loader/index.js +261 -256
- package/compiled/sass-loader/index.js +24 -20
- package/compiled/sass-loader/package.json +1 -1
- package/compiled/semver/index.js +188 -170
- package/compiled/semver/package.json +1 -1
- package/compiled/style-loader/index.js +13 -13
- package/compiled/webpack-bundle-analyzer/index.js +198 -198
- package/compiled/webpack-merge/index.js +29 -29
- package/dist/bundler-config/chunkSplit.cjs +169 -156
- package/dist/bundler-config/chunkSplit.js +125 -134
- package/dist/bundler-config/css.cjs +181 -158
- package/dist/bundler-config/css.js +139 -151
- package/dist/bundler-config/experimentCss.cjs +203 -159
- package/dist/bundler-config/experimentCss.js +162 -152
- package/dist/bundler-config/helper.cjs +82 -78
- package/dist/bundler-config/helper.js +36 -55
- package/dist/bundler-config/index.cjs +260 -209
- package/dist/bundler-config/index.d.ts.map +1 -1
- package/dist/bundler-config/index.js +209 -182
- package/dist/bundler-config/jsMinify.cjs +114 -95
- package/dist/bundler-config/jsMinify.js +70 -73
- package/dist/colors.cjs +83 -56
- package/dist/colors.js +38 -37
- package/dist/config.cjs +107 -93
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +64 -70
- package/dist/constants.cjs +65 -62
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +22 -38
- package/dist/createUnpack.cjs +111 -104
- package/dist/createUnpack.js +67 -82
- package/dist/global.cjs +36 -0
- package/dist/global.d.ts +2 -0
- package/dist/global.d.ts.map +1 -0
- package/dist/global.js +4 -0
- package/dist/index.cjs +174 -51
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -15
- package/dist/lightningcss/loader.cjs +56 -53
- package/dist/lightningcss/loader.d.ts.map +1 -1
- package/dist/lightningcss/loader.js +25 -34
- package/dist/lightningcss/minimizer.cjs +90 -109
- package/dist/lightningcss/minimizer.d.ts.map +1 -1
- package/dist/lightningcss/minimizer.js +59 -87
- package/dist/logger.cjs +104 -98
- package/dist/logger.js +59 -76
- package/dist/openBrowser.cjs +104 -81
- package/dist/openBrowser.js +56 -52
- package/dist/plugin-progress/rspack.cjs +104 -79
- package/dist/plugin-progress/rspack.js +59 -57
- package/dist/plugin-progress/webpack.cjs +111 -89
- package/dist/plugin-progress/webpack.js +65 -67
- package/dist/plugin.cjs +38 -29
- package/dist/plugin.js +8 -17
- package/dist/prebundleDeps.cjs +327 -337
- package/dist/prebundleDeps.d.ts.map +1 -1
- package/dist/prebundleDeps.js +278 -324
- package/dist/progressBar.cjs +82 -65
- package/dist/progressBar.js +38 -43
- package/dist/reporter.cjs +149 -124
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +102 -102
- package/dist/run/build.cjs +68 -67
- package/dist/run/build.js +24 -45
- package/dist/run/dev.cjs +96 -83
- package/dist/run/dev.d.ts.map +1 -1
- package/dist/run/dev.js +50 -61
- package/dist/run/index.cjs +74 -21
- package/dist/run/index.js +2 -9
- package/dist/typed-css-modules/loader.cjs +179 -188
- package/dist/typed-css-modules/loader.js +118 -151
- package/dist/typed-css-modules/plugin.cjs +113 -88
- package/dist/typed-css-modules/plugin.js +68 -66
- package/dist/typed-css-modules/utils.cjs +43 -42
- package/dist/typed-css-modules/utils.js +13 -30
- package/dist/types/chunkSplit.cjs +19 -15
- package/dist/types/chunkSplit.d.ts +2 -10
- package/dist/types/chunkSplit.d.ts.map +1 -1
- package/dist/types/chunkSplit.js +2 -9
- package/dist/types/config.cjs +19 -15
- package/dist/types/config.js +2 -9
- package/dist/types/index.cjs +101 -27
- package/dist/types/index.js +2 -9
- package/dist/types/lightningcss.cjs +19 -15
- package/dist/types/lightningcss.js +2 -9
- package/dist/types/logger.cjs +43 -34
- package/dist/types/logger.js +13 -22
- package/dist/types/plugin.cjs +19 -15
- package/dist/types/plugin.js +2 -9
- package/dist/utils.cjs +280 -304
- package/dist/utils.js +195 -241
- package/dist/watchFiles.cjs +73 -0
- package/dist/watchFiles.d.ts +3 -0
- package/dist/watchFiles.d.ts.map +1 -0
- package/dist/watchFiles.js +27 -0
- package/package.json +18 -21
- package/compiled/commander/index.d.ts +0 -1047
- package/compiled/commander/index.js +0 -2428
- package/compiled/commander/license +0 -22
- package/compiled/commander/package.json +0 -1
- package/dist/bundleRequire.cjs +0 -200
- package/dist/bundleRequire.d.ts +0 -5
- package/dist/bundleRequire.d.ts.map +0 -1
- package/dist/bundleRequire.js +0 -173
- package/dist/lightningcss/cache.cjs +0 -36
- package/dist/lightningcss/cache.d.ts +0 -2
- package/dist/lightningcss/cache.d.ts.map +0 -1
- package/dist/lightningcss/cache.js +0 -22
package/dist/run/dev.js
CHANGED
|
@@ -1,66 +1,55 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { openBrowser } from "../openBrowser.js";
|
|
14
|
-
import { prebundleDeps } from "../prebundleDeps.js";
|
|
15
|
-
import { getAddressUrls, getPort, isString } from "../utils.js";
|
|
16
|
-
import webpack from "webpack";
|
|
17
|
-
import WebpackDevServer from "webpack-dev-server";
|
|
18
|
-
import { getBundlerConfig } from "../bundler-config/index.js";
|
|
1
|
+
import __rslib_shim_module__ from 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__ from "@rspack/core";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__ from "../colors.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__global_js_83d0ec5c__ from "../global.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__logger_js_ff791b17__ from "../logger.js";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE__openBrowser_js_007107e2__ from "../openBrowser.js";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE__prebundleDeps_js_142f70dc__ from "../prebundleDeps.js";
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__ from "../utils.js";
|
|
10
|
+
import * as __WEBPACK_EXTERNAL_MODULE_webpack__ from "webpack";
|
|
11
|
+
import * as __WEBPACK_EXTERNAL_MODULE_webpack_dev_server_0dd3124e__ from "webpack-dev-server";
|
|
12
|
+
import * as __WEBPACK_EXTERNAL_MODULE__bundler_config_index_js_e76188c2__ from "../bundler-config/index.js";
|
|
19
13
|
async function bundlerDev(originalUnpackConfig) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
unpackConfig = await prebundleDeps({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
14
|
+
var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1;
|
|
15
|
+
let unpackConfig = originalUnpackConfig;
|
|
16
|
+
const bundler = 'rspack' === unpackConfig.bundler ? __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack : __WEBPACK_EXTERNAL_MODULE_webpack__["default"];
|
|
17
|
+
if (null === (_unpackConfig_dev = unpackConfig.dev) || void 0 === _unpackConfig_dev ? void 0 : _unpackConfig_dev.prebundle) unpackConfig = await (0, __WEBPACK_EXTERNAL_MODULE__prebundleDeps_js_142f70dc__.prebundleDeps)({
|
|
18
|
+
unpackConfig
|
|
19
|
+
});
|
|
20
|
+
const config = await (0, __WEBPACK_EXTERNAL_MODULE__bundler_config_index_js_e76188c2__.getBundlerConfig)(unpackConfig);
|
|
21
|
+
const compiler = bundler(config);
|
|
22
|
+
const port = await (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.getPort)(null === (_unpackConfig_server = unpackConfig.server) || void 0 === _unpackConfig_server ? void 0 : _unpackConfig_server.port);
|
|
23
|
+
const devServerOptions = {
|
|
24
|
+
hot: true,
|
|
25
|
+
port,
|
|
26
|
+
open: false,
|
|
27
|
+
client: {
|
|
28
|
+
overlay: false
|
|
29
|
+
},
|
|
30
|
+
proxy: null === (_unpackConfig_server1 = unpackConfig.server) || void 0 === _unpackConfig_server1 ? void 0 : _unpackConfig_server1.proxy,
|
|
31
|
+
devMiddleware: {
|
|
32
|
+
writeToDisk: null === (_unpackConfig_dev1 = unpackConfig.dev) || void 0 === _unpackConfig_dev1 ? void 0 : _unpackConfig_dev1.writeToDisk
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const server = new __WEBPACK_EXTERNAL_MODULE_webpack_dev_server_0dd3124e__["default"](devServerOptions, compiler);
|
|
36
|
+
__WEBPACK_EXTERNAL_MODULE__logger_js_ff791b17__.logger.greet(` ${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].green(`${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].bold('UNPACK')} v1.7.7`)} ${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].dim(`ready in ${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].reset(__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].bold(Math.ceil(performance.now() - global.__unpack_start_time)))}ms`)}\n`);
|
|
37
|
+
printAddressUrls(port);
|
|
38
|
+
await server.start();
|
|
39
|
+
__WEBPACK_EXTERNAL_MODULE__global_js_83d0ec5c__.restartCleaners.push(async ()=>await server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())));
|
|
40
|
+
const { open } = unpackConfig.server;
|
|
41
|
+
if (open) {
|
|
42
|
+
const url = (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.isString)(open) ? open : `http://localhost:${port}`;
|
|
43
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__openBrowser_js_007107e2__.openBrowser)(url);
|
|
38
44
|
}
|
|
39
|
-
};
|
|
40
|
-
const server = new WebpackDevServer(devServerOptions, compiler);
|
|
41
|
-
logger.greet(
|
|
42
|
-
` ${colors.green(`${colors.bold("UNPACK")} v${"1.7.5"}`)} ${colors.dim(
|
|
43
|
-
`ready in ${colors.reset(
|
|
44
|
-
colors.bold(Math.ceil(performance.now() - global.__unpack_start_time))
|
|
45
|
-
)}ms`
|
|
46
|
-
)}
|
|
47
|
-
`
|
|
48
|
-
);
|
|
49
|
-
printAddressUrls(port);
|
|
50
|
-
await server.start();
|
|
51
|
-
const { open } = unpackConfig.server;
|
|
52
|
-
if (open) {
|
|
53
|
-
const url = isString(open) ? open : `http://localhost:${port}`;
|
|
54
|
-
await openBrowser(url);
|
|
55
|
-
}
|
|
56
45
|
}
|
|
57
46
|
function printAddressUrls(port) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
const addressUrls = (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.getAddressUrls)({
|
|
48
|
+
port
|
|
49
|
+
});
|
|
50
|
+
const colorUrl = (url)=>__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].cyan(url.replace(/:(\d+)\//, (_, port)=>`:${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].bold(port)}/`));
|
|
51
|
+
addressUrls.forEach((addr)=>{
|
|
52
|
+
console.log(` ${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].green('➜')} ${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].bold(addr.label)}${colorUrl(addr.url)}`);
|
|
53
|
+
});
|
|
63
54
|
}
|
|
64
|
-
export {
|
|
65
|
-
bundlerDev
|
|
66
|
-
};
|
|
55
|
+
export { bundlerDev };
|
package/dist/run/index.cjs
CHANGED
|
@@ -1,23 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./build": function(module) {
|
|
4
|
+
module.exports = require("./build.cjs");
|
|
5
|
+
},
|
|
6
|
+
"./dev": function(module) {
|
|
7
|
+
module.exports = require("./dev.cjs");
|
|
8
|
+
}
|
|
12
9
|
};
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
var __webpack_module_cache__ = {};
|
|
11
|
+
function __webpack_require__(moduleId) {
|
|
12
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
13
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
14
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
15
|
+
exports: {}
|
|
16
|
+
};
|
|
17
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
18
|
+
return module.exports;
|
|
19
|
+
}
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.n = function(module) {
|
|
22
|
+
var getter = module && module.__esModule ? function() {
|
|
23
|
+
return module['default'];
|
|
24
|
+
} : function() {
|
|
25
|
+
return module;
|
|
26
|
+
};
|
|
27
|
+
__webpack_require__.d(getter, {
|
|
28
|
+
a: getter
|
|
29
|
+
});
|
|
30
|
+
return getter;
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
(()=>{
|
|
34
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
35
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: definition[key]
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
(()=>{
|
|
42
|
+
__webpack_require__.o = function(obj, prop) {
|
|
43
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
(()=>{
|
|
47
|
+
__webpack_require__.r = function(exports1) {
|
|
48
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
49
|
+
value: 'Module'
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
52
|
+
value: true
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
var __webpack_exports__ = {};
|
|
57
|
+
(()=>{
|
|
58
|
+
__webpack_require__.r(__webpack_exports__);
|
|
59
|
+
var _build__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./build");
|
|
60
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
61
|
+
for(var __WEBPACK_IMPORT_KEY__ in _build__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
62
|
+
return _build__WEBPACK_IMPORTED_MODULE_0__[key];
|
|
63
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
64
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
65
|
+
var _dev__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./dev");
|
|
66
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
67
|
+
for(var __WEBPACK_IMPORT_KEY__ in _dev__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
68
|
+
return _dev__WEBPACK_IMPORTED_MODULE_1__[key];
|
|
69
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
70
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
71
|
+
})();
|
|
72
|
+
var __webpack_export_target__ = exports;
|
|
73
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
74
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
75
|
+
value: true
|
|
23
76
|
});
|
package/dist/run/index.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
-
var getDirname = () => path.dirname(getFilename());
|
|
8
|
-
var __dirname = /* @__PURE__ */ getDirname();
|
|
9
|
-
var __filename = /* @__PURE__ */ getFilename();
|
|
1
|
+
import __rslib_shim_module__ from 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
10
3
|
export * from "./build.js";
|
|
11
4
|
export * from "./dev.js";
|
|
@@ -1,195 +1,186 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var loader_exports = {};
|
|
29
|
-
__export(loader_exports, {
|
|
30
|
-
default: () => loader_default,
|
|
31
|
-
isInNodeModules: () => isInNodeModules,
|
|
32
|
-
wrapQuotes: () => wrapQuotes
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(loader_exports);
|
|
35
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
36
|
-
var import_node_path = __toESM(require("node:path"));
|
|
37
|
-
var import_constants = require("../constants.cjs");
|
|
38
|
-
var import_utils = require("./utils.cjs");
|
|
39
|
-
const LineDiff = require("../../compiled/line-diff/index.js");
|
|
40
|
-
const isInNodeModules = (path2) => import_constants.NODE_MODULES_REGEX.test(path2);
|
|
41
|
-
const getNoDeclarationFileError = ({ filename }) => new Error(
|
|
42
|
-
`Generated type declaration does not exist. Run Unpack and commit the type declaration for '${filename}'`
|
|
43
|
-
);
|
|
44
|
-
const getTypeMismatchError = ({
|
|
45
|
-
filename,
|
|
46
|
-
expected,
|
|
47
|
-
actual
|
|
48
|
-
}) => {
|
|
49
|
-
const diff = new LineDiff(enforceLFLineSeparators(actual), expected).toString();
|
|
50
|
-
return new Error(
|
|
51
|
-
`Generated type declaration file is outdated. Run Unpack and commit the updated type declaration for '${filename}'
|
|
52
|
-
|
|
53
|
-
${diff}`
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
function wrapQuotes(key) {
|
|
57
|
-
const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
|
|
58
|
-
if (isValidIdentifier) {
|
|
59
|
-
return key;
|
|
60
|
-
}
|
|
61
|
-
return `'${key}'`;
|
|
62
|
-
}
|
|
63
|
-
const cssModuleToNamedExports = (cssModuleKeys) => {
|
|
64
|
-
return cssModuleKeys.sort().map((key) => `export const ${key}: string;`).join("\n");
|
|
65
|
-
};
|
|
66
|
-
const cssModuleToInterface = (cssModulesKeys) => {
|
|
67
|
-
const interfaceFields = cssModulesKeys.sort().map((key) => ` ${wrapQuotes(key)}: string;`).join("\n");
|
|
68
|
-
return `interface CssExports {
|
|
69
|
-
${interfaceFields}
|
|
70
|
-
}`;
|
|
71
|
-
};
|
|
72
|
-
const filenameToTypingsFilename = (filename) => {
|
|
73
|
-
const dirName = import_node_path.default.dirname(filename);
|
|
74
|
-
const baseName = import_node_path.default.basename(filename);
|
|
75
|
-
return import_node_path.default.join(dirName, `${baseName}.d.ts`);
|
|
76
|
-
};
|
|
77
|
-
const enforceLFLineSeparators = (text) => {
|
|
78
|
-
if (text) {
|
|
79
|
-
return text.replace(/\r\n/g, "\n");
|
|
80
|
-
}
|
|
81
|
-
return text;
|
|
82
|
-
};
|
|
83
|
-
const compareText = (contentA, contentB) => {
|
|
84
|
-
return enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
|
|
85
|
-
};
|
|
86
|
-
const validModes = ["emit", "verify"];
|
|
87
|
-
const isFileNotFound = (err) => err && err.code === "ENOENT";
|
|
88
|
-
const makeDoneHandlers = (callback, content, rest) => ({
|
|
89
|
-
failed: (e) => callback(e),
|
|
90
|
-
success: () => callback(null, content, ...rest)
|
|
91
|
-
});
|
|
92
|
-
const makeFileHandlers = (filename) => ({
|
|
93
|
-
read: (handler) => import_node_fs.default.readFile(filename, { encoding: "utf-8" }, handler),
|
|
94
|
-
write: (content, handler) => import_node_fs.default.writeFile(filename, content, { encoding: "utf-8" }, handler)
|
|
95
|
-
});
|
|
96
|
-
const extractLocalExports = (content) => {
|
|
97
|
-
let localExports = content.split("exports.locals")[1];
|
|
98
|
-
if (!localExports) {
|
|
99
|
-
localExports = content.split("___CSS_LOADER_EXPORT___.locals")[1];
|
|
100
|
-
}
|
|
101
|
-
return localExports;
|
|
102
|
-
};
|
|
103
|
-
const getCSSModulesKeys = (content, namedExport) => {
|
|
104
|
-
const keys = /* @__PURE__ */ new Set();
|
|
105
|
-
if (namedExport) {
|
|
106
|
-
const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
|
|
107
|
-
let match2 = exportsRegex.exec(content);
|
|
108
|
-
while (match2 !== null) {
|
|
109
|
-
keys.add(match2[1]);
|
|
110
|
-
match2 = exportsRegex.exec(content);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"compiled/line-diff/index.js": function(module) {
|
|
4
|
+
module.exports = require("/home/runner/work/unpack/unpack/packages/core/compiled/line-diff/index.js");
|
|
111
5
|
}
|
|
112
|
-
return Array.from(keys);
|
|
113
|
-
}
|
|
114
|
-
const localExports = extractLocalExports(content);
|
|
115
|
-
const keyRegex = /"([^\\"]+)":/g;
|
|
116
|
-
let match = keyRegex.exec(localExports);
|
|
117
|
-
while (match !== null) {
|
|
118
|
-
keys.add(match[1]);
|
|
119
|
-
match = keyRegex.exec(localExports);
|
|
120
|
-
}
|
|
121
|
-
return Array.from(keys);
|
|
122
6
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
${cssModuleToInterface(keys)}
|
|
133
|
-
${cssModuleExport}`;
|
|
7
|
+
var __webpack_module_cache__ = {};
|
|
8
|
+
function __webpack_require__(moduleId) {
|
|
9
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
+
exports: {}
|
|
13
|
+
};
|
|
14
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
+
return module.exports;
|
|
134
16
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.n = function(module) {
|
|
19
|
+
var getter = module && module.__esModule ? function() {
|
|
20
|
+
return module['default'];
|
|
21
|
+
} : function() {
|
|
22
|
+
return module;
|
|
23
|
+
};
|
|
24
|
+
__webpack_require__.d(getter, {
|
|
25
|
+
a: getter
|
|
26
|
+
});
|
|
27
|
+
return getter;
|
|
28
|
+
};
|
|
29
|
+
})();
|
|
30
|
+
(()=>{
|
|
31
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
32
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: definition[key]
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
(()=>{
|
|
39
|
+
__webpack_require__.o = function(obj, prop) {
|
|
40
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
(()=>{
|
|
44
|
+
__webpack_require__.r = function(exports1) {
|
|
45
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
46
|
+
value: 'Module'
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
49
|
+
value: true
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
})();
|
|
53
|
+
var __webpack_exports__ = {};
|
|
54
|
+
(()=>{
|
|
55
|
+
__webpack_require__.r(__webpack_exports__);
|
|
56
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
57
|
+
isInNodeModules: ()=>isInNodeModules,
|
|
58
|
+
wrapQuotes: ()=>wrapQuotes,
|
|
59
|
+
default: ()=>loader_rslib_entry_
|
|
174
60
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
61
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
62
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
63
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
64
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
65
|
+
const external_constants_cjs_namespaceObject = require("../constants.cjs");
|
|
66
|
+
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
67
|
+
const LineDiff = __webpack_require__("compiled/line-diff/index.js");
|
|
68
|
+
const isInNodeModules = (path)=>external_constants_cjs_namespaceObject.NODE_MODULES_REGEX.test(path);
|
|
69
|
+
const getNoDeclarationFileError = ({ filename })=>new Error(`Generated type declaration does not exist. Run Unpack and commit the type declaration for '${filename}'`);
|
|
70
|
+
const getTypeMismatchError = ({ filename, expected, actual })=>{
|
|
71
|
+
const diff = new LineDiff(enforceLFLineSeparators(actual), expected).toString();
|
|
72
|
+
return new Error(`Generated type declaration file is outdated. Run Unpack and commit the updated type declaration for '${filename}'\n\n${diff}`);
|
|
73
|
+
};
|
|
74
|
+
function wrapQuotes(key) {
|
|
75
|
+
const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
|
|
76
|
+
if (isValidIdentifier) return key;
|
|
77
|
+
return `'${key}'`;
|
|
78
|
+
}
|
|
79
|
+
const cssModuleToNamedExports = (cssModuleKeys)=>cssModuleKeys.sort().map((key)=>`export const ${key}: string;`).join('\n');
|
|
80
|
+
const cssModuleToInterface = (cssModulesKeys)=>{
|
|
81
|
+
const interfaceFields = cssModulesKeys.sort().map((key)=>` ${wrapQuotes(key)}: string;`).join('\n');
|
|
82
|
+
return `interface CssExports {\n${interfaceFields}\n}`;
|
|
83
|
+
};
|
|
84
|
+
const filenameToTypingsFilename = (filename)=>{
|
|
85
|
+
const dirName = external_node_path_default().dirname(filename);
|
|
86
|
+
const baseName = external_node_path_default().basename(filename);
|
|
87
|
+
return external_node_path_default().join(dirName, `${baseName}.d.ts`);
|
|
88
|
+
};
|
|
89
|
+
const enforceLFLineSeparators = (text)=>{
|
|
90
|
+
if (text) return text.replace(/\r\n/g, '\n');
|
|
91
|
+
return text;
|
|
92
|
+
};
|
|
93
|
+
const compareText = (contentA, contentB)=>enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
|
|
94
|
+
const validModes = [
|
|
95
|
+
'emit',
|
|
96
|
+
'verify'
|
|
97
|
+
];
|
|
98
|
+
const isFileNotFound = (err)=>err && 'ENOENT' === err.code;
|
|
99
|
+
const makeDoneHandlers = (callback, content, rest)=>({
|
|
100
|
+
failed: (e)=>callback(e),
|
|
101
|
+
success: ()=>callback(null, content, ...rest)
|
|
102
|
+
});
|
|
103
|
+
const makeFileHandlers = (filename)=>({
|
|
104
|
+
read: (handler)=>external_node_fs_default().readFile(filename, {
|
|
105
|
+
encoding: 'utf-8'
|
|
106
|
+
}, handler),
|
|
107
|
+
write: (content, handler)=>external_node_fs_default().writeFile(filename, content, {
|
|
108
|
+
encoding: 'utf-8'
|
|
109
|
+
}, handler)
|
|
110
|
+
});
|
|
111
|
+
const extractLocalExports = (content)=>{
|
|
112
|
+
let localExports = content.split('exports.locals')[1];
|
|
113
|
+
if (!localExports) localExports = content.split('___CSS_LOADER_EXPORT___.locals')[1];
|
|
114
|
+
return localExports;
|
|
115
|
+
};
|
|
116
|
+
const getCSSModulesKeys = (content, namedExport)=>{
|
|
117
|
+
const keys = new Set();
|
|
118
|
+
if (namedExport) {
|
|
119
|
+
const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
|
|
120
|
+
let match = exportsRegex.exec(content);
|
|
121
|
+
while(null !== match){
|
|
122
|
+
keys.add(match[1]);
|
|
123
|
+
match = exportsRegex.exec(content);
|
|
124
|
+
}
|
|
125
|
+
return Array.from(keys);
|
|
126
|
+
}
|
|
127
|
+
const localExports = extractLocalExports(content);
|
|
128
|
+
const keyRegex = /"([^\\"]+)":/g;
|
|
129
|
+
let match = keyRegex.exec(localExports);
|
|
130
|
+
while(null !== match){
|
|
131
|
+
keys.add(match[1]);
|
|
132
|
+
match = keyRegex.exec(localExports);
|
|
133
|
+
}
|
|
134
|
+
return Array.from(keys);
|
|
135
|
+
};
|
|
136
|
+
function codegen(keys, namedExport) {
|
|
137
|
+
const bannerMessage = '// Generated automatically, do not edit';
|
|
138
|
+
if (namedExport) return `${bannerMessage}\n${cssModuleToNamedExports(keys)}\n`;
|
|
139
|
+
const cssModuleExport = 'declare const cssExports: CssExports;\nexport default cssExports;\n';
|
|
140
|
+
return `${bannerMessage}\n${cssModuleToInterface(keys)}\n${cssModuleExport}`;
|
|
141
|
+
}
|
|
142
|
+
function loader_rslib_entry_(content, ...rest) {
|
|
143
|
+
const { failed, success } = makeDoneHandlers(this.async(), content, rest);
|
|
144
|
+
const { resourcePath } = this;
|
|
145
|
+
const { mode = 'emit', modules } = this.getOptions() || {};
|
|
146
|
+
if (!validModes.includes(mode)) {
|
|
147
|
+
failed(new Error(`Invalid mode option: ${mode}`));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!(0, external_utils_cjs_namespaceObject.isCSSModules)({
|
|
151
|
+
resourcePath,
|
|
152
|
+
modules
|
|
153
|
+
}) || isInNodeModules(resourcePath)) {
|
|
182
154
|
success();
|
|
183
|
-
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const cssModuleInterfaceFilename = filenameToTypingsFilename(resourcePath);
|
|
158
|
+
const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);
|
|
159
|
+
const namedExport = external_constants_cjs_namespaceObject.CSS_NAMED_EXPORT;
|
|
160
|
+
const cssModulesKeys = getCSSModulesKeys(content, namedExport);
|
|
161
|
+
const cssModulesCode = codegen(cssModulesKeys, namedExport);
|
|
162
|
+
read('verify' === mode ? (err, fileContents)=>{
|
|
163
|
+
if (isFileNotFound(err)) return failed(getNoDeclarationFileError({
|
|
164
|
+
filename: cssModuleInterfaceFilename
|
|
165
|
+
}));
|
|
166
|
+
if (err) return failed(err);
|
|
167
|
+
if (!compareText(cssModulesCode, fileContents)) return failed(getTypeMismatchError({
|
|
168
|
+
filename: cssModuleInterfaceFilename,
|
|
169
|
+
expected: cssModulesCode,
|
|
170
|
+
actual: fileContents
|
|
171
|
+
}));
|
|
172
|
+
return success();
|
|
173
|
+
} : (_, fileContents)=>{
|
|
174
|
+
if (compareText(cssModulesCode, fileContents)) success();
|
|
175
|
+
else write(cssModulesCode, (err)=>{
|
|
176
|
+
if (err) failed(err);
|
|
177
|
+
else success();
|
|
178
|
+
});
|
|
184
179
|
});
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
192
|
-
0 && (module.exports = {
|
|
193
|
-
isInNodeModules,
|
|
194
|
-
wrapQuotes
|
|
180
|
+
}
|
|
181
|
+
})();
|
|
182
|
+
var __webpack_export_target__ = exports;
|
|
183
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
184
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
185
|
+
value: true
|
|
195
186
|
});
|