@unpackjs/core 1.7.4 → 1.7.6
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 +178 -178
- package/compiled/less-loader/index.js +11 -11
- package/compiled/line-diff/index.js +4 -4
- package/compiled/portfinder/index.js +37 -37
- package/compiled/postcss-loader/index.js +261 -256
- package/compiled/sass-loader/index.js +18 -18
- 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.d.ts +1 -1
- package/dist/bundler-config/chunkSplit.js +125 -134
- package/dist/bundler-config/css.cjs +181 -158
- package/dist/bundler-config/css.d.ts +1 -1
- package/dist/bundler-config/css.js +139 -151
- package/dist/bundler-config/experimentCss.cjs +203 -159
- package/dist/bundler-config/experimentCss.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +64 -70
- package/dist/constants.cjs +62 -62
- package/dist/constants.js +20 -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/cache.cjs +40 -32
- package/dist/lightningcss/cache.js +10 -20
- package/dist/lightningcss/loader.cjs +56 -53
- package/dist/lightningcss/loader.d.ts +1 -1
- package/dist/lightningcss/loader.js +25 -34
- package/dist/lightningcss/minimizer.cjs +90 -109
- package/dist/lightningcss/minimizer.d.ts +1 -1
- package/dist/lightningcss/minimizer.js +59 -87
- package/dist/logger.cjs +104 -98
- package/dist/logger.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/plugin-progress/rspack.js +59 -57
- package/dist/plugin-progress/webpack.cjs +111 -89
- package/dist/plugin-progress/webpack.d.ts +1 -1
- 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 +135 -120
- package/dist/reporter.js +88 -98
- package/dist/run/build.cjs +68 -67
- package/dist/run/build.d.ts +1 -1
- package/dist/run/build.js +24 -45
- package/dist/run/dev.cjs +96 -83
- package/dist/run/dev.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/typed-css-modules/loader.js +118 -151
- package/dist/typed-css-modules/plugin.cjs +113 -88
- package/dist/typed-css-modules/plugin.d.ts +1 -1
- package/dist/typed-css-modules/plugin.js +68 -66
- package/dist/typed-css-modules/utils.cjs +43 -42
- package/dist/typed-css-modules/utils.d.ts +1 -1
- 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.d.ts +1 -5
- package/dist/types/config.d.ts.map +1 -1
- 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 +14 -17
- package/compiled/commander/index.d.ts +0 -971
- package/compiled/commander/index.js +0 -2190
- 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
|
@@ -1,170 +1,137 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const LineDiff = require("../../compiled/line-diff/index.js");
|
|
13
|
-
import { CSS_NAMED_EXPORT, NODE_MODULES_REGEX } from "../constants.js";
|
|
14
|
-
import { isCSSModules } from "./utils.js";
|
|
15
|
-
const isInNodeModules = (path3) => NODE_MODULES_REGEX.test(path3);
|
|
16
|
-
const getNoDeclarationFileError = ({ filename }) => new Error(
|
|
17
|
-
`Generated type declaration does not exist. Run Unpack and commit the type declaration for '${filename}'`
|
|
18
|
-
);
|
|
19
|
-
const getTypeMismatchError = ({
|
|
20
|
-
filename,
|
|
21
|
-
expected,
|
|
22
|
-
actual
|
|
23
|
-
}) => {
|
|
24
|
-
const diff = new LineDiff(enforceLFLineSeparators(actual), expected).toString();
|
|
25
|
-
return new Error(
|
|
26
|
-
`Generated type declaration file is outdated. Run Unpack and commit the updated type declaration for '${filename}'
|
|
27
|
-
|
|
28
|
-
${diff}`
|
|
29
|
-
);
|
|
1
|
+
import __rslib_shim_module__ from 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__home_runner_work_unpack_unpack_packages_core_compiled_line_diff_index_js_5432ea9f__ from "/home/runner/work/unpack/unpack/packages/core/compiled/line-diff/index.js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__constants_js_59e7fa1b__ from "../constants.js";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__ from "./utils.js";
|
|
8
|
+
var __webpack_modules__ = {
|
|
9
|
+
"compiled/line-diff/index.js": function(module) {
|
|
10
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__home_runner_work_unpack_unpack_packages_core_compiled_line_diff_index_js_5432ea9f__;
|
|
11
|
+
}
|
|
30
12
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
var __webpack_module_cache__ = {};
|
|
14
|
+
function __webpack_require__(moduleId) {
|
|
15
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
16
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
17
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
18
|
+
exports: {}
|
|
19
|
+
};
|
|
20
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
21
|
+
return module.exports;
|
|
37
22
|
}
|
|
38
|
-
const
|
|
39
|
-
|
|
23
|
+
const LineDiff = __webpack_require__("compiled/line-diff/index.js");
|
|
24
|
+
const isInNodeModules = (path)=>__WEBPACK_EXTERNAL_MODULE__constants_js_59e7fa1b__.NODE_MODULES_REGEX.test(path);
|
|
25
|
+
const getNoDeclarationFileError = ({ filename })=>new Error(`Generated type declaration does not exist. Run Unpack and commit the type declaration for '${filename}'`);
|
|
26
|
+
const getTypeMismatchError = ({ filename, expected, actual })=>{
|
|
27
|
+
const diff = new LineDiff(enforceLFLineSeparators(actual), expected).toString();
|
|
28
|
+
return new Error(`Generated type declaration file is outdated. Run Unpack and commit the updated type declaration for '${filename}'\n\n${diff}`);
|
|
40
29
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
${
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return path2.join(dirName, `${baseName}.d.ts`);
|
|
30
|
+
function wrapQuotes(key) {
|
|
31
|
+
const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
|
|
32
|
+
if (isValidIdentifier) return key;
|
|
33
|
+
return `'${key}'`;
|
|
34
|
+
}
|
|
35
|
+
const cssModuleToNamedExports = (cssModuleKeys)=>cssModuleKeys.sort().map((key)=>`export const ${key}: string;`).join('\n');
|
|
36
|
+
const cssModuleToInterface = (cssModulesKeys)=>{
|
|
37
|
+
const interfaceFields = cssModulesKeys.sort().map((key)=>` ${wrapQuotes(key)}: string;`).join('\n');
|
|
38
|
+
return `interface CssExports {\n${interfaceFields}\n}`;
|
|
51
39
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return text;
|
|
40
|
+
const filenameToTypingsFilename = (filename)=>{
|
|
41
|
+
const dirName = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(filename);
|
|
42
|
+
const baseName = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filename);
|
|
43
|
+
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dirName, `${baseName}.d.ts`);
|
|
57
44
|
};
|
|
58
|
-
const
|
|
59
|
-
|
|
45
|
+
const enforceLFLineSeparators = (text)=>{
|
|
46
|
+
if (text) return text.replace(/\r\n/g, '\n');
|
|
47
|
+
return text;
|
|
60
48
|
};
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
49
|
+
const compareText = (contentA, contentB)=>enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
|
|
50
|
+
const validModes = [
|
|
51
|
+
'emit',
|
|
52
|
+
'verify'
|
|
53
|
+
];
|
|
54
|
+
const isFileNotFound = (err)=>err && 'ENOENT' === err.code;
|
|
55
|
+
const makeDoneHandlers = (callback, content, rest)=>({
|
|
56
|
+
failed: (e)=>callback(e),
|
|
57
|
+
success: ()=>callback(null, content, ...rest)
|
|
58
|
+
});
|
|
59
|
+
const makeFileHandlers = (filename)=>({
|
|
60
|
+
read: (handler)=>__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFile(filename, {
|
|
61
|
+
encoding: 'utf-8'
|
|
62
|
+
}, handler),
|
|
63
|
+
write: (content, handler)=>__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFile(filename, content, {
|
|
64
|
+
encoding: 'utf-8'
|
|
65
|
+
}, handler)
|
|
66
|
+
});
|
|
67
|
+
const extractLocalExports = (content)=>{
|
|
68
|
+
let localExports = content.split('exports.locals')[1];
|
|
69
|
+
if (!localExports) localExports = content.split('___CSS_LOADER_EXPORT___.locals')[1];
|
|
70
|
+
return localExports;
|
|
77
71
|
};
|
|
78
|
-
const getCSSModulesKeys = (content, namedExport)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
const getCSSModulesKeys = (content, namedExport)=>{
|
|
73
|
+
const keys = new Set();
|
|
74
|
+
if (namedExport) {
|
|
75
|
+
const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
|
|
76
|
+
let match = exportsRegex.exec(content);
|
|
77
|
+
while(null !== match){
|
|
78
|
+
keys.add(match[1]);
|
|
79
|
+
match = exportsRegex.exec(content);
|
|
80
|
+
}
|
|
81
|
+
return Array.from(keys);
|
|
82
|
+
}
|
|
83
|
+
const localExports = extractLocalExports(content);
|
|
84
|
+
const keyRegex = /"([^\\"]+)":/g;
|
|
85
|
+
let match = keyRegex.exec(localExports);
|
|
86
|
+
while(null !== match){
|
|
87
|
+
keys.add(match[1]);
|
|
88
|
+
match = keyRegex.exec(localExports);
|
|
86
89
|
}
|
|
87
90
|
return Array.from(keys);
|
|
88
|
-
}
|
|
89
|
-
const localExports = extractLocalExports(content);
|
|
90
|
-
const keyRegex = /"([^\\"]+)":/g;
|
|
91
|
-
let match = keyRegex.exec(localExports);
|
|
92
|
-
while (match !== null) {
|
|
93
|
-
keys.add(match[1]);
|
|
94
|
-
match = keyRegex.exec(localExports);
|
|
95
|
-
}
|
|
96
|
-
return Array.from(keys);
|
|
97
91
|
};
|
|
98
92
|
function codegen(keys, namedExport) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
${
|
|
103
|
-
`;
|
|
104
|
-
}
|
|
105
|
-
const cssModuleExport = "declare const cssExports: CssExports;\nexport default cssExports;\n";
|
|
106
|
-
return `${bannerMessage}
|
|
107
|
-
${cssModuleToInterface(keys)}
|
|
108
|
-
${cssModuleExport}`;
|
|
93
|
+
const bannerMessage = '// Generated automatically, do not edit';
|
|
94
|
+
if (namedExport) return `${bannerMessage}\n${cssModuleToNamedExports(keys)}\n`;
|
|
95
|
+
const cssModuleExport = 'declare const cssExports: CssExports;\nexport default cssExports;\n';
|
|
96
|
+
return `${bannerMessage}\n${cssModuleToInterface(keys)}\n${cssModuleExport}`;
|
|
109
97
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
98
|
+
function loader_rslib_entry_(content, ...rest) {
|
|
99
|
+
const { failed, success } = makeDoneHandlers(this.async(), content, rest);
|
|
100
|
+
const { resourcePath } = this;
|
|
101
|
+
const { mode = 'emit', modules } = this.getOptions() || {};
|
|
102
|
+
if (!validModes.includes(mode)) {
|
|
103
|
+
failed(new Error(`Invalid mode option: ${mode}`));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!(0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.isCSSModules)({
|
|
107
|
+
resourcePath,
|
|
108
|
+
modules
|
|
109
|
+
}) || isInNodeModules(resourcePath)) {
|
|
110
|
+
success();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const cssModuleInterfaceFilename = filenameToTypingsFilename(resourcePath);
|
|
114
|
+
const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);
|
|
115
|
+
const namedExport = __WEBPACK_EXTERNAL_MODULE__constants_js_59e7fa1b__.CSS_NAMED_EXPORT;
|
|
116
|
+
const cssModulesKeys = getCSSModulesKeys(content, namedExport);
|
|
117
|
+
const cssModulesCode = codegen(cssModulesKeys, namedExport);
|
|
118
|
+
read('verify' === mode ? (err, fileContents)=>{
|
|
119
|
+
if (isFileNotFound(err)) return failed(getNoDeclarationFileError({
|
|
132
120
|
filename: cssModuleInterfaceFilename
|
|
133
|
-
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
if (err) {
|
|
137
|
-
return failed(err);
|
|
138
|
-
}
|
|
139
|
-
if (!compareText(cssModulesCode, fileContents)) {
|
|
140
|
-
return failed(
|
|
141
|
-
getTypeMismatchError({
|
|
121
|
+
}));
|
|
122
|
+
if (err) return failed(err);
|
|
123
|
+
if (!compareText(cssModulesCode, fileContents)) return failed(getTypeMismatchError({
|
|
142
124
|
filename: cssModuleInterfaceFilename,
|
|
143
125
|
expected: cssModulesCode,
|
|
144
126
|
actual: fileContents
|
|
145
|
-
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (!compareText(cssModulesCode, fileContents)) {
|
|
153
|
-
write(cssModulesCode, (err) => {
|
|
154
|
-
if (err) {
|
|
155
|
-
failed(err);
|
|
156
|
-
} else {
|
|
157
|
-
success();
|
|
158
|
-
}
|
|
127
|
+
}));
|
|
128
|
+
return success();
|
|
129
|
+
} : (_, fileContents)=>{
|
|
130
|
+
if (compareText(cssModulesCode, fileContents)) success();
|
|
131
|
+
else write(cssModulesCode, (err)=>{
|
|
132
|
+
if (err) failed(err);
|
|
133
|
+
else success();
|
|
159
134
|
});
|
|
160
|
-
} else {
|
|
161
|
-
success();
|
|
162
|
-
}
|
|
163
135
|
});
|
|
164
|
-
}
|
|
165
136
|
}
|
|
166
|
-
export {
|
|
167
|
-
loader_default as default,
|
|
168
|
-
isInNodeModules,
|
|
169
|
-
wrapQuotes
|
|
170
|
-
};
|
|
137
|
+
export { loader_rslib_entry_ as default, isInNodeModules, wrapQuotes };
|
|
@@ -1,96 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = function(module) {
|
|
5
|
+
var getter = module && module.__esModule ? function() {
|
|
6
|
+
return module['default'];
|
|
7
|
+
} : function() {
|
|
8
|
+
return module;
|
|
9
|
+
};
|
|
10
|
+
__webpack_require__.d(getter, {
|
|
11
|
+
a: getter
|
|
12
|
+
});
|
|
13
|
+
return getter;
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
18
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: definition[key]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = function(obj, prop) {
|
|
26
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
27
|
+
};
|
|
28
|
+
})();
|
|
29
|
+
(()=>{
|
|
30
|
+
__webpack_require__.r = function(exports1) {
|
|
31
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
32
|
+
value: 'Module'
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __webpack_exports__ = {};
|
|
40
|
+
__webpack_require__.r(__webpack_exports__);
|
|
41
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
+
PluginTypedCssModules: ()=>PluginTypedCssModules
|
|
31
43
|
});
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
const
|
|
44
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
45
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
46
|
+
const external_constants_cjs_namespaceObject = require("../constants.cjs");
|
|
47
|
+
const external_logger_cjs_namespaceObject = require("../logger.cjs");
|
|
48
|
+
const external_tinyglobby_namespaceObject = require("tinyglobby");
|
|
49
|
+
const external_typed_css_modules_namespaceObject = require("typed-css-modules");
|
|
50
|
+
var external_typed_css_modules_default = /*#__PURE__*/ __webpack_require__.n(external_typed_css_modules_namespaceObject);
|
|
51
|
+
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
52
|
+
function _define_property(obj, key, value) {
|
|
53
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
54
|
+
value: value,
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
writable: true
|
|
58
|
+
});
|
|
59
|
+
else obj[key] = value;
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
const statPromise = external_node_fs_default().promises.stat;
|
|
40
63
|
async function writeFile(dtsCreator, cssFile) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return `// Generated automatically, do not edit
|
|
44
|
-
${definition}`;
|
|
45
|
-
});
|
|
64
|
+
const content = await dtsCreator.create(cssFile, void 0, true);
|
|
65
|
+
await content.writeFile((definition)=>`// Generated automatically, do not edit\n${definition}`);
|
|
46
66
|
}
|
|
47
67
|
async function generateTypingIfNecessary(dtsCreator, cssFile) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return writeFile(dtsCreator, cssFile);
|
|
57
|
-
}
|
|
68
|
+
let typingStat;
|
|
69
|
+
try {
|
|
70
|
+
typingStat = await statPromise(`${cssFile}.d.ts`);
|
|
71
|
+
} catch (_) {
|
|
72
|
+
return writeFile(dtsCreator, cssFile);
|
|
73
|
+
}
|
|
74
|
+
const cssFileStat = await statPromise(cssFile);
|
|
75
|
+
if (cssFileStat.mtime.getTime() > typingStat.mtime.getTime()) return writeFile(dtsCreator, cssFile);
|
|
58
76
|
}
|
|
59
|
-
const PLUGIN_NAME =
|
|
77
|
+
const PLUGIN_NAME = 'PluginTypedCssModules';
|
|
60
78
|
class PluginTypedCssModules {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
await
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
79
|
+
apply(compiler) {
|
|
80
|
+
compiler.hooks.run.tapPromise(PLUGIN_NAME, async ()=>{
|
|
81
|
+
await this.generateCssTypings(this.useIncremental);
|
|
82
|
+
});
|
|
83
|
+
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async ()=>{
|
|
84
|
+
try {
|
|
85
|
+
await this.generateCssTypings(this.useIncremental);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
external_logger_cjs_namespaceObject.logger.error(err.toString());
|
|
88
|
+
} finally{
|
|
89
|
+
this.useIncremental = true;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async generateCssTypings(incremental) {
|
|
94
|
+
const files = await (0, external_tinyglobby_namespaceObject.glob)(this.globPattern);
|
|
95
|
+
const cssModulesFiles = files.filter((file)=>{
|
|
96
|
+
var _this_userOptions;
|
|
97
|
+
return (0, external_utils_cjs_namespaceObject.isCSSModules)({
|
|
98
|
+
resourcePath: file,
|
|
99
|
+
modules: null === (_this_userOptions = this.userOptions) || void 0 === _this_userOptions ? void 0 : _this_userOptions.modules
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
const doTask = incremental ? generateTypingIfNecessary : writeFile;
|
|
103
|
+
return Promise.all(cssModulesFiles.map((file)=>doTask(this.dtsCreator, file)));
|
|
104
|
+
}
|
|
105
|
+
constructor(options){
|
|
106
|
+
_define_property(this, "dtsCreator", void 0);
|
|
107
|
+
_define_property(this, "useIncremental", false);
|
|
108
|
+
_define_property(this, "globPattern", 'src/**/*.{css,less,scss}');
|
|
109
|
+
_define_property(this, "userOptions", void 0);
|
|
110
|
+
this.userOptions = options;
|
|
111
|
+
this.dtsCreator = new (external_typed_css_modules_default())({
|
|
112
|
+
camelCase: true,
|
|
113
|
+
namedExports: external_constants_cjs_namespaceObject.CSS_NAMED_EXPORT
|
|
114
|
+
});
|
|
115
|
+
}
|
|
92
116
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
117
|
+
var __webpack_export_target__ = exports;
|
|
118
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
119
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
120
|
+
value: true
|
|
96
121
|
});
|