@unpackjs/core 3.5.2 → 3.5.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/index.cjs
CHANGED
|
@@ -713,8 +713,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
713
713
|
let getOutputFilename = ({ type, hash, async })=>{
|
|
714
714
|
let FILENAME = isProd() && !1 !== hash ? PROD_DEFAULT_FILENAME : DEV_DEFAULT_FILENAME;
|
|
715
715
|
return async ? 'js' === type ? FILENAME.jsAsync : FILENAME.cssAsync : FILENAME[type];
|
|
716
|
-
}
|
|
717
|
-
var external_typed_css_modules_default = __webpack_require__.n(external_typed_css_modules_namespaceObject);
|
|
716
|
+
};
|
|
718
717
|
function _define_property(obj, key, value) {
|
|
719
718
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
720
719
|
value: value,
|
|
@@ -723,63 +722,12 @@ for(var __webpack_i__ in (()=>{
|
|
|
723
722
|
writable: !0
|
|
724
723
|
}) : obj[key] = value, obj;
|
|
725
724
|
}
|
|
726
|
-
let statPromise = external_node_fs_default().promises.stat, DtsCreator = external_typed_css_modules_default().default || external_typed_css_modules_default();
|
|
727
|
-
async function writeFile(dtsCreator, cssFile) {
|
|
728
|
-
let content = await dtsCreator.create(cssFile, void 0, !0);
|
|
729
|
-
await content.writeFile((definition)=>`// Generated automatically, do not edit\n${definition}`);
|
|
730
|
-
}
|
|
731
|
-
async function generateTypingIfNecessary(dtsCreator, cssFile) {
|
|
732
|
-
let typingStat;
|
|
733
|
-
try {
|
|
734
|
-
typingStat = await statPromise(`${cssFile}.d.ts`);
|
|
735
|
-
} catch {
|
|
736
|
-
return writeFile(dtsCreator, cssFile);
|
|
737
|
-
}
|
|
738
|
-
if ((await statPromise(cssFile)).mtime.getTime() > typingStat.mtime.getTime()) return writeFile(dtsCreator, cssFile);
|
|
739
|
-
}
|
|
740
|
-
let typedCssModules_PLUGIN_NAME = 'TypedCssModulesPlugin';
|
|
741
|
-
class TypedCssModulesPlugin {
|
|
742
|
-
apply(compiler) {
|
|
743
|
-
compiler.hooks.run.tapPromise(typedCssModules_PLUGIN_NAME, async ()=>{
|
|
744
|
-
await this.generateCssTypings(this.useIncremental);
|
|
745
|
-
}), compiler.hooks.watchRun.tap(typedCssModules_PLUGIN_NAME, ()=>{
|
|
746
|
-
setTimeout(()=>{
|
|
747
|
-
this.generateCssTypings(this.useIncremental).catch((err)=>{
|
|
748
|
-
logger_logger.error(err.toString());
|
|
749
|
-
}).finally(()=>{
|
|
750
|
-
this.useIncremental = !0;
|
|
751
|
-
});
|
|
752
|
-
}, 100);
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
async generateCssTypings(incremental) {
|
|
756
|
-
let cssModulesFiles = (await (0, external_tinyglobby_namespaceObject.glob)(this.globPattern)).filter((file)=>isCSSModules({
|
|
757
|
-
resourcePath: file,
|
|
758
|
-
modules: this.userOptions?.modules
|
|
759
|
-
})), doTask = incremental ? generateTypingIfNecessary : writeFile;
|
|
760
|
-
return Promise.all(cssModulesFiles.map((file)=>doTask(this.dtsCreator, file)));
|
|
761
|
-
}
|
|
762
|
-
constructor(options){
|
|
763
|
-
_define_property(this, "dtsCreator", void 0), _define_property(this, "useIncremental", !1), _define_property(this, "globPattern", 'src/**/*.{css,less,scss}'), _define_property(this, "userOptions", void 0), this.userOptions = options, this.dtsCreator = new DtsCreator({
|
|
764
|
-
camelCase: !0,
|
|
765
|
-
namedExports: !1
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
function jsMinify_define_property(obj, key, value) {
|
|
770
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
771
|
-
value: value,
|
|
772
|
-
enumerable: !0,
|
|
773
|
-
configurable: !0,
|
|
774
|
-
writable: !0
|
|
775
|
-
}) : obj[key] = value, obj;
|
|
776
|
-
}
|
|
777
725
|
let { RawSource, SourceMapSource } = core_namespaceObject.rspack.sources, isJsFile = /\.[cm]?js(\?.*)?$/i, jsMinify_PLUGIN_NAME = 'JsMinifyPlugin';
|
|
778
726
|
class JsMinifyPlugin {
|
|
779
727
|
apply(compiler) {
|
|
780
728
|
let meta = JSON.stringify({
|
|
781
729
|
name: jsMinify_PLUGIN_NAME,
|
|
782
|
-
version: "3.5.
|
|
730
|
+
version: "3.5.3",
|
|
783
731
|
options: this.minifyOptions
|
|
784
732
|
});
|
|
785
733
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -814,7 +762,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
814
762
|
}));
|
|
815
763
|
}
|
|
816
764
|
constructor(options = {}){
|
|
817
|
-
|
|
765
|
+
_define_property(this, "minifyOptions", void 0), _define_property(this, "customMinify", void 0);
|
|
818
766
|
const { implementation, ...minifyOptions } = options;
|
|
819
767
|
this.customMinify = implementation?.minify, this.minifyOptions = minifyOptions;
|
|
820
768
|
}
|
|
@@ -1409,9 +1357,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1409
1357
|
type: 'css'
|
|
1410
1358
|
}
|
|
1411
1359
|
].filter(Boolean)
|
|
1412
|
-
}),
|
|
1413
|
-
modules
|
|
1414
|
-
})), config;
|
|
1360
|
+
}), config;
|
|
1415
1361
|
}({
|
|
1416
1362
|
config,
|
|
1417
1363
|
unpackConfig
|
|
@@ -1925,7 +1871,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1925
1871
|
req.headers.accept?.includes('html') && (req.url = '/index.html'), next();
|
|
1926
1872
|
}), middlewares.unshift(core_namespaceObject.experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1927
1873
|
let server = new dev_server_namespaceObject.RspackDevServer(devServerOptions, compiler);
|
|
1928
|
-
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.5.
|
|
1874
|
+
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.5.3`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - global.__unpack_start_time))} ${colors.dim('ms')}\n`), printAddressUrls(port, unpackConfig.server?.host), addRestartCleaner(()=>server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())));
|
|
1929
1875
|
let open = unpackConfig.server?.open, url = isString(open) ? open : `http://localhost:${port}`;
|
|
1930
1876
|
open && openBrowser(url), setupCliShortcuts({
|
|
1931
1877
|
openPage: async ()=>{
|
|
@@ -1998,7 +1944,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1998
1944
|
...mergeConfig(defaultConfig, config),
|
|
1999
1945
|
_context: {
|
|
2000
1946
|
callerName,
|
|
2001
|
-
version: "3.5.
|
|
1947
|
+
version: "3.5.3"
|
|
2002
1948
|
}
|
|
2003
1949
|
};
|
|
2004
1950
|
};
|
|
@@ -2006,7 +1952,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2006
1952
|
build: async ({ watch } = {})=>{
|
|
2007
1953
|
setNodeEnv(watch ? 'development' : 'production');
|
|
2008
1954
|
let config = resolveConfig();
|
|
2009
|
-
console.log(colors.brand(`${callerName} v3.5.
|
|
1955
|
+
console.log(colors.brand(`${callerName} v3.5.3`), colors.cyan(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
|
|
2010
1956
|
},
|
|
2011
1957
|
dev: async ()=>{
|
|
2012
1958
|
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,6 @@ import portfinder from "portfinder";
|
|
|
12
12
|
import { expand } from "dotenv-expand";
|
|
13
13
|
import node_assert from "node:assert";
|
|
14
14
|
import { glob, globSync } from "tinyglobby";
|
|
15
|
-
import typed_css_modules from "typed-css-modules";
|
|
16
15
|
import { promisify } from "node:util";
|
|
17
16
|
import node_zlib from "node:zlib";
|
|
18
17
|
import { RspackDevServer } from "@rspack/dev-server";
|
|
@@ -637,63 +636,12 @@ function _define_property(obj, key, value) {
|
|
|
637
636
|
writable: !0
|
|
638
637
|
}) : obj[key] = value, obj;
|
|
639
638
|
}
|
|
640
|
-
let statPromise = node_fs.promises.stat, DtsCreator = typed_css_modules.default || typed_css_modules;
|
|
641
|
-
async function writeFile(dtsCreator, cssFile) {
|
|
642
|
-
let content = await dtsCreator.create(cssFile, void 0, !0);
|
|
643
|
-
await content.writeFile((definition)=>`// Generated automatically, do not edit\n${definition}`);
|
|
644
|
-
}
|
|
645
|
-
async function generateTypingIfNecessary(dtsCreator, cssFile) {
|
|
646
|
-
let typingStat;
|
|
647
|
-
try {
|
|
648
|
-
typingStat = await statPromise(`${cssFile}.d.ts`);
|
|
649
|
-
} catch {
|
|
650
|
-
return writeFile(dtsCreator, cssFile);
|
|
651
|
-
}
|
|
652
|
-
if ((await statPromise(cssFile)).mtime.getTime() > typingStat.mtime.getTime()) return writeFile(dtsCreator, cssFile);
|
|
653
|
-
}
|
|
654
|
-
let typedCssModules_PLUGIN_NAME = 'TypedCssModulesPlugin';
|
|
655
|
-
class TypedCssModulesPlugin {
|
|
656
|
-
apply(compiler) {
|
|
657
|
-
compiler.hooks.run.tapPromise(typedCssModules_PLUGIN_NAME, async ()=>{
|
|
658
|
-
await this.generateCssTypings(this.useIncremental);
|
|
659
|
-
}), compiler.hooks.watchRun.tap(typedCssModules_PLUGIN_NAME, ()=>{
|
|
660
|
-
setTimeout(()=>{
|
|
661
|
-
this.generateCssTypings(this.useIncremental).catch((err)=>{
|
|
662
|
-
logger_logger.error(err.toString());
|
|
663
|
-
}).finally(()=>{
|
|
664
|
-
this.useIncremental = !0;
|
|
665
|
-
});
|
|
666
|
-
}, 100);
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
async generateCssTypings(incremental) {
|
|
670
|
-
let cssModulesFiles = (await glob(this.globPattern)).filter((file)=>isCSSModules({
|
|
671
|
-
resourcePath: file,
|
|
672
|
-
modules: this.userOptions?.modules
|
|
673
|
-
})), doTask = incremental ? generateTypingIfNecessary : writeFile;
|
|
674
|
-
return Promise.all(cssModulesFiles.map((file)=>doTask(this.dtsCreator, file)));
|
|
675
|
-
}
|
|
676
|
-
constructor(options){
|
|
677
|
-
_define_property(this, "dtsCreator", void 0), _define_property(this, "useIncremental", !1), _define_property(this, "globPattern", 'src/**/*.{css,less,scss}'), _define_property(this, "userOptions", void 0), this.userOptions = options, this.dtsCreator = new DtsCreator({
|
|
678
|
-
camelCase: !0,
|
|
679
|
-
namedExports: !1
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
function jsMinify_define_property(obj, key, value) {
|
|
684
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
685
|
-
value: value,
|
|
686
|
-
enumerable: !0,
|
|
687
|
-
configurable: !0,
|
|
688
|
-
writable: !0
|
|
689
|
-
}) : obj[key] = value, obj;
|
|
690
|
-
}
|
|
691
639
|
let { RawSource, SourceMapSource } = rspack.sources, isJsFile = /\.[cm]?js(\?.*)?$/i, jsMinify_PLUGIN_NAME = 'JsMinifyPlugin';
|
|
692
640
|
class JsMinifyPlugin {
|
|
693
641
|
apply(compiler) {
|
|
694
642
|
let meta = JSON.stringify({
|
|
695
643
|
name: jsMinify_PLUGIN_NAME,
|
|
696
|
-
version: "3.5.
|
|
644
|
+
version: "3.5.3",
|
|
697
645
|
options: this.minifyOptions
|
|
698
646
|
});
|
|
699
647
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -728,7 +676,7 @@ class JsMinifyPlugin {
|
|
|
728
676
|
}));
|
|
729
677
|
}
|
|
730
678
|
constructor(options = {}){
|
|
731
|
-
|
|
679
|
+
_define_property(this, "minifyOptions", void 0), _define_property(this, "customMinify", void 0);
|
|
732
680
|
let { implementation, ...minifyOptions } = options;
|
|
733
681
|
this.customMinify = implementation?.minify, this.minifyOptions = minifyOptions;
|
|
734
682
|
}
|
|
@@ -1319,9 +1267,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1319
1267
|
type: 'css'
|
|
1320
1268
|
}
|
|
1321
1269
|
].filter(Boolean)
|
|
1322
|
-
}),
|
|
1323
|
-
modules
|
|
1324
|
-
})), config;
|
|
1270
|
+
}), config;
|
|
1325
1271
|
}({
|
|
1326
1272
|
config,
|
|
1327
1273
|
unpackConfig
|
|
@@ -1833,7 +1779,7 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1833
1779
|
req.headers.accept?.includes('html') && (req.url = '/index.html'), next();
|
|
1834
1780
|
}), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1835
1781
|
let server = new RspackDevServer(devServerOptions, compiler);
|
|
1836
|
-
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.5.
|
|
1782
|
+
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.5.3`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - global.__unpack_start_time))} ${colors.dim('ms')}\n`), printAddressUrls(port, unpackConfig.server?.host), addRestartCleaner(()=>server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())));
|
|
1837
1783
|
let open = unpackConfig.server?.open, url = isString(open) ? open : `http://localhost:${port}`;
|
|
1838
1784
|
open && openBrowser(url), setupCliShortcuts({
|
|
1839
1785
|
openPage: async ()=>{
|
|
@@ -1906,7 +1852,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
|
1906
1852
|
...mergeConfig(defaultConfig, config),
|
|
1907
1853
|
_context: {
|
|
1908
1854
|
callerName,
|
|
1909
|
-
version: "3.5.
|
|
1855
|
+
version: "3.5.3"
|
|
1910
1856
|
}
|
|
1911
1857
|
};
|
|
1912
1858
|
};
|
|
@@ -1914,7 +1860,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
|
1914
1860
|
build: async ({ watch } = {})=>{
|
|
1915
1861
|
setNodeEnv(watch ? 'development' : 'production');
|
|
1916
1862
|
let config = resolveConfig();
|
|
1917
|
-
console.log(colors.brand(`${callerName} v3.5.
|
|
1863
|
+
console.log(colors.brand(`${callerName} v3.5.3`), colors.cyan(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
|
|
1918
1864
|
},
|
|
1919
1865
|
dev: async ()=>{
|
|
1920
1866
|
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimentCss.d.ts","sourceRoot":"","sources":["../../src/bundler-config/experimentCss.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAU,YAAY,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"experimentCss.d.ts","sourceRoot":"","sources":["../../src/bundler-config/experimentCss.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAU,YAAY,EAAE,MAAM,WAAW,CAAA;AAc3E,wBAAgB,wBAAwB,CAAC,EACvC,MAAM,EACN,YAAY,GACb,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,GAAG,oBAAoB,CA4IvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpackjs/core",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.3",
|
|
4
4
|
"description": "An Rspack-based build tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -53,8 +53,7 @@
|
|
|
53
53
|
"postcss": "8.5.6",
|
|
54
54
|
"thread-loader": "4.0.4",
|
|
55
55
|
"tinyglobby": "0.2.15",
|
|
56
|
-
"ts-checker-rspack-plugin": "1.2.0"
|
|
57
|
-
"typed-css-modules": "0.9.1"
|
|
56
|
+
"ts-checker-rspack-plugin": "1.2.0"
|
|
58
57
|
},
|
|
59
58
|
"scripts": {
|
|
60
59
|
"dev": "rslib build --watch",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Rspack, UnpackConfig } from '../../types';
|
|
2
|
-
type TypedCssModulesPluginOptions = {
|
|
3
|
-
modules?: NonNullable<UnpackConfig['css']>['modules'];
|
|
4
|
-
};
|
|
5
|
-
export declare class TypedCssModulesPlugin {
|
|
6
|
-
private dtsCreator;
|
|
7
|
-
private useIncremental;
|
|
8
|
-
private globPattern;
|
|
9
|
-
userOptions: TypedCssModulesPluginOptions;
|
|
10
|
-
constructor(options: TypedCssModulesPluginOptions);
|
|
11
|
-
apply(compiler: Rspack.Compiler): void;
|
|
12
|
-
private generateCssTypings;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=typedCssModules.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typedCssModules.d.ts","sourceRoot":"","sources":["../../../src/bundler-config/plugins/typedCssModules.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAmCrD,KAAK,4BAA4B,GAAG;IAClC,OAAO,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;CACtD,CAAA;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,WAAW,CAA6B;IAChD,WAAW,EAAE,4BAA4B,CAAA;gBAE7B,OAAO,EAAE,4BAA4B;IAQjD,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YAqBjB,kBAAkB;CAQjC"}
|