@unpackjs/core 3.9.0 → 3.9.2
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.js
CHANGED
|
@@ -528,7 +528,12 @@ let removeDir = (dir)=>{
|
|
|
528
528
|
recursive: !0,
|
|
529
529
|
force: !0
|
|
530
530
|
});
|
|
531
|
-
}, STYLE_IMPORT_RE = /import\s+([\s\S]+?)\s+from\s+(['"])(.*?\.(?:css|less|scss|sass))\2/g,
|
|
531
|
+
}, STYLE_IMPORT_RE = /import\s+([\s\S]+?)\s+from\s+(['"])(.*?\.(?:css|less|scss|sass))\2/g, TYPE_IMPORT_CLAUSE_RE = /^\s*type\b/, STYLE_EXT_HINTS = [
|
|
532
|
+
'.css',
|
|
533
|
+
'.less',
|
|
534
|
+
'.scss',
|
|
535
|
+
'.sass'
|
|
536
|
+
], BROWSER_LOGS_ENDPOINT = '/__browser_logs__', browserLogs_SCRIPT_REGEX = /\.(js|jsx|mjs|cjs|ts|tsx|mts|cts|vue|svelte)$/, gzip = promisify(node_zlib.gzip), numberFormatter = new Intl.NumberFormat('en', {
|
|
532
537
|
maximumFractionDigits: 2,
|
|
533
538
|
minimumFractionDigits: 2
|
|
534
539
|
}), displaySize = (bytes)=>`${numberFormatter.format(bytes / 1000)} kB`;
|
|
@@ -749,7 +754,7 @@ class JsMinifyPlugin {
|
|
|
749
754
|
apply(compiler) {
|
|
750
755
|
let meta = JSON.stringify({
|
|
751
756
|
name: jsMinify_PLUGIN_NAME,
|
|
752
|
-
version: "3.9.
|
|
757
|
+
version: "3.9.2",
|
|
753
758
|
options: this.minifyOptions
|
|
754
759
|
});
|
|
755
760
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -1581,7 +1586,7 @@ async function unpackDev(unpackConfig) {
|
|
|
1581
1586
|
...middlewares
|
|
1582
1587
|
]);
|
|
1583
1588
|
let server = new RspackDevServer(devServerOptions, compiler);
|
|
1584
|
-
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.9.
|
|
1589
|
+
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.9.2${unpackConfig.performance?.cache ? ' ϟ' : ''}`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - getUnpackStartTime()))} ${colors.dim('ms')}\n`), printServerUrls({
|
|
1585
1590
|
port,
|
|
1586
1591
|
host: unpackConfig.server.host,
|
|
1587
1592
|
base: unpackConfig.base
|
|
@@ -1595,10 +1600,10 @@ async function unpackDev(unpackConfig) {
|
|
|
1595
1600
|
function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'unpack' }) {
|
|
1596
1601
|
let _context = {
|
|
1597
1602
|
callerName,
|
|
1598
|
-
version: "3.9.
|
|
1603
|
+
version: "3.9.2",
|
|
1599
1604
|
cachePath: 'node_modules/.unpack'
|
|
1600
1605
|
}, resolveConfig = (mode)=>{
|
|
1601
|
-
let rootPath, outputPath, basePath, cachedTraceMap, fs, isValidMethodName, parseFrame, formatOriginalLocation, formatFullStack, resolveErrorLocationAndStack, shouldTransformDeepImport, preJsAssets, jsAssets, cssAssets, bundledDepsCachePath, deepImportPkgPattern, deepImportRegex, root;
|
|
1606
|
+
let rootPath, outputPath, basePath, cachedTraceMap, fs, isValidMethodName, parseFrame, formatOriginalLocation, formatFullStack, resolveErrorLocationAndStack, shouldTransformDeepImport, preJsAssets, jsAssets, cssAssets, bundledDepsCachePath, deepImportPkgPattern, deepImportRegex, plugin, root;
|
|
1602
1607
|
return {
|
|
1603
1608
|
...mergeConfig({
|
|
1604
1609
|
root: cwd,
|
|
@@ -1639,7 +1644,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
1639
1644
|
filter: {
|
|
1640
1645
|
test: JSX_REGEX
|
|
1641
1646
|
},
|
|
1642
|
-
handler: (code)=>code.replace(STYLE_IMPORT_RE, (full, importClause, quote, spec)=>
|
|
1647
|
+
handler: (code)=>STYLE_EXT_HINTS.some((ext)=>code.includes(ext)) ? code.replace(STYLE_IMPORT_RE, (full, importClause, quote, spec)=>TYPE_IMPORT_CLAUSE_RE.test(importClause) || spec.includes('?') || spec.includes('#') ? full : `import ${importClause} from ${quote}${spec}?module${quote}`) : null
|
|
1643
1648
|
}
|
|
1644
1649
|
},
|
|
1645
1650
|
(rootPath = '', outputPath = '', basePath = '/', cachedTraceMap = new Map(), fs = null, isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.test(methodName), parseFrame = async (frame)=>{
|
|
@@ -1885,18 +1890,16 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
1885
1890
|
format(cleanedTemplate, ...rest)
|
|
1886
1891
|
];
|
|
1887
1892
|
})(formattedArgs), prefix = colors.dim(`[browser ${time}]`);
|
|
1888
|
-
switch(
|
|
1893
|
+
switch(level){
|
|
1889
1894
|
case 'error':
|
|
1890
|
-
|
|
1895
|
+
console.log(colors.red(`${prefix} ${format(...outputArgs)}`));
|
|
1891
1896
|
break;
|
|
1892
1897
|
case 'warn':
|
|
1893
|
-
|
|
1898
|
+
console.log(colors.yellow(`${prefix} ${format(...outputArgs)}`));
|
|
1894
1899
|
break;
|
|
1895
1900
|
case 'debug':
|
|
1896
|
-
|
|
1901
|
+
console.log(prefix, ...outputArgs);
|
|
1897
1902
|
}
|
|
1898
|
-
} catch (e) {
|
|
1899
|
-
logger_logger.error('Failed to parse browser log payload', e);
|
|
1900
1903
|
} finally{
|
|
1901
1904
|
res.statusCode = 204, res.end();
|
|
1902
1905
|
}
|
|
@@ -1907,7 +1910,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
1907
1910
|
}),
|
|
1908
1911
|
(shouldTransformDeepImport = !1, preJsAssets = [], jsAssets = [], cssAssets = [], bundledDepsCachePath = '', deepImportPkgPattern = [
|
|
1909
1912
|
...SPECIAL_NO_ENTRY_DEPS
|
|
1910
|
-
].sort((a, b)=>b.length - a.length).map((name)=>name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'), deepImportRegex = RegExp(`import\\s+([a-zA-Z0-9_$]+)\\s+from\\s+['"]((${deepImportPkgPattern})/[^'"]+)['"]`, 'g'), {
|
|
1913
|
+
].sort((a, b)=>b.length - a.length).map((name)=>name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'), deepImportRegex = RegExp(`import\\s+([a-zA-Z0-9_$]+)\\s+from\\s+['"]((${deepImportPkgPattern})/[^'"]+)['"]`, 'g'), plugin = {
|
|
1911
1914
|
name: 'unpack:prebundle',
|
|
1912
1915
|
apply: (config, { command })=>'dev' === command && !!config.dev?.prebundle,
|
|
1913
1916
|
config: async (config, context)=>{
|
|
@@ -2139,16 +2142,15 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
2139
2142
|
return config.externals = [
|
|
2140
2143
|
externals1,
|
|
2141
2144
|
...existingExternals
|
|
2142
|
-
],
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
}) : null
|
|
2145
|
+
], shouldTransformDeepImport && (plugin.transform = {
|
|
2146
|
+
filter: {
|
|
2147
|
+
test: JSX_REGEX
|
|
2148
|
+
},
|
|
2149
|
+
handler: (code)=>SPECIAL_NO_ENTRY_DEPS.some((pkg)=>code.includes(pkg)) ? code.replace(deepImportRegex, (_, localName, importPath, pkgName)=>{
|
|
2150
|
+
let exportName = pathToExportIdentifier(importPath.slice(pkgName.length + 1));
|
|
2151
|
+
return `import { ${exportName} as ${localName} } from '${pkgName}'`;
|
|
2152
|
+
}) : null
|
|
2153
|
+
}), config;
|
|
2152
2154
|
},
|
|
2153
2155
|
transformHtml: (html)=>injectToHead(html, preJsAssets.sort((a, b)=>a.order - b.order).map((item)=>item.path).map((item)=>`<script defer src="${item}"></script>`).join('')),
|
|
2154
2156
|
setupMiddlewares: (middlewares)=>[
|
|
@@ -2265,7 +2267,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
2265
2267
|
let mode = watch ? 'development' : 'production';
|
|
2266
2268
|
setNodeEnv(mode);
|
|
2267
2269
|
let config = resolveConfig(mode);
|
|
2268
|
-
console.log(colors.brand(`${callerName} v3.9.
|
|
2270
|
+
console.log(colors.brand(`${callerName} v3.9.2${config.performance?.cache ? ' ϟ' : ''}`), colors.cyan(`building for ${mode}...`)), await unpackBuild(config);
|
|
2269
2271
|
},
|
|
2270
2272
|
dev: async ()=>{
|
|
2271
2273
|
setUnpackStartTime(performance.now());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoCssModules.d.ts","sourceRoot":"","sources":["../../src/plugins/autoCssModules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"autoCssModules.d.ts","sourceRoot":"","sources":["../../src/plugins/autoCssModules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAM7C,eAAO,MAAM,oBAAoB,QAAO,YAoBvC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserLogs.d.ts","sourceRoot":"","sources":["../../src/plugins/browserLogs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browserLogs.d.ts","sourceRoot":"","sources":["../../src/plugins/browserLogs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AA6B7C,eAAO,MAAM,iBAAiB,QAAO,YAgZpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prebundle.d.ts","sourceRoot":"","sources":["../../src/plugins/prebundle.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,WAAW,CAAA;AAkGnE,eAAO,MAAM,eAAe,QAAO,
|
|
1
|
+
{"version":3,"file":"prebundle.d.ts","sourceRoot":"","sources":["../../src/plugins/prebundle.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,WAAW,CAAA;AAkGnE,eAAO,MAAM,eAAe,QAAO,YAiZlC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpackjs/core",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.2",
|
|
4
4
|
"description": "An Rspack-based build tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
39
|
-
"@rsdoctor/rspack-plugin": "1.
|
|
39
|
+
"@rsdoctor/rspack-plugin": "1.5.0",
|
|
40
40
|
"@rspack/core": "1.7.2",
|
|
41
41
|
"@rspack/dev-server": "1.1.5",
|
|
42
42
|
"chokidar": "5.0.0",
|