@moneko/core 3.26.13-beta.5 → 3.26.13-beta.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/lib/bin/build.d.mts +1 -1
- package/lib/bin/build.mjs +1 -1
- package/lib/bin/convert.d.mts +33 -10
- package/lib/bin/convert.mjs +1 -1
- package/lib/bin/index.d.mts +0 -0
- package/lib/bin/index.mjs +0 -0
- package/package.json +1 -2
package/lib/bin/build.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import { argv } from 'node:process';
|
|
3
|
-
import {
|
|
3
|
+
import { ink, println, removeDir } from '@moneko/utils';
|
|
4
4
|
import setupEnv from '../commom/setup-env.mjs';
|
|
5
5
|
import { cwd, swcCachePath } from './utils/config.mjs';
|
|
6
6
|
import { getSwcOption } from './utils/setup-swcrc.mjs';
|
package/lib/bin/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as o}from"node:path";import{argv as
|
|
1
|
+
import{join as o}from"node:path";import{argv as t}from"node:process";import{ink as e,println as s,removeDir as i}from"@moneko/utils";import r from"../commom/setup-env.mjs";import{cwd as m,swcCachePath as n}from"./utils/config.mjs";import{getSwcOption as l}from"./utils/setup-swcrc.mjs";import p from"./convert.mjs";import{lesscCommonjs as c}from"./lessc.mjs";import d from"./tsc.mjs";async function u(){let u=t[3],a=t[4],f=t.slice(5);u||(s(e(`type: 无效值 ${e(u,"245")}`,"red")),process.exit(1));let j=!f.includes("no-docs"),y=!f.includes("no-lib"),b=!f.includes("no-es"),g=!f.includes("no-dts"),x=f.filter(o=>!["no-docs","no-es","no-lib"].includes(o));if(await r("production",u,a,x),"library"===u){let{CONFIG:t}=await import("../config.mjs"),e="swc"===t.dts,s=[y&&{type:"commonjs",dir:"lib",msg:"Convert to CommonJS"},b&&{type:"es6",dir:"es",msg:"Convert to ES Module"}].filter(Boolean);for(let t=0,r=s.length;t<r;t++){i(o(m,`./${s[t].dir}`));let r=l(a);"es6"===s[t].type&&(r.jsc.target="es2015"),r.jsc.experimental.emitIsolatedDts=g&&e,r.jsc.experimental.cacheRoot=n,r.module.type=s[t].type,p({outDir:s[t].dir,inputDir:"components",copy:!0,ignore:[/^.*\/__*__\//,/\.test\.(js|ts)x?$/,/\.DS_Store/,/README\.mdx?/,/examples\//],options:r}),"commonjs"===s[t].type&&c(),g&&!e&&d(s[t].dir)}}("library"!==u||j&&"library"===u)&&import("../build.mjs")}export default u;
|
package/lib/bin/convert.d.mts
CHANGED
|
@@ -1,14 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createDir, ink, println, scanFolderSync, updateFile } from '@moneko/utils';
|
|
4
|
+
import { JsMinifyOptions, type Options, type Output, transformFile } from '@swc/core';
|
|
5
|
+
declare function getOutfilePath(outDir: string, file: string, outFileExtension?: string);
|
|
6
|
+
interface ConvertOptions {
|
|
4
7
|
outDir: string;
|
|
5
|
-
|
|
8
|
+
inputDir: string;
|
|
9
|
+
options: Options;
|
|
10
|
+
ignore?: RegExp[];
|
|
6
11
|
extensions?: string[];
|
|
7
|
-
|
|
8
|
-
outFileExtension?: string;
|
|
12
|
+
copy?: boolean;
|
|
9
13
|
quiet?: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
outputExtension?: string;
|
|
15
|
+
}
|
|
16
|
+
interface ConvertResult {
|
|
17
|
+
duration: number;
|
|
18
|
+
compiled: string[];
|
|
19
|
+
copied: string[];
|
|
20
|
+
failed: string[];
|
|
21
|
+
}
|
|
22
|
+
interface ConvertOutput extends Output {
|
|
23
|
+
output?: string;
|
|
24
|
+
}
|
|
25
|
+
declare const normalizeExtension: Record<string, string>;
|
|
26
|
+
declare const jscMinify: JsMinifyOptions;
|
|
27
|
+
declare async function convert({ ignore = [], quiet = true, copy = true, outDir, outputExtension, inputDir, options, extensions = [
|
|
28
|
+
'.ts',
|
|
29
|
+
'.js',
|
|
30
|
+
'.tsx',
|
|
31
|
+
'.jsx',
|
|
32
|
+
'.mts',
|
|
33
|
+
'.mjs',
|
|
34
|
+
'.cts',
|
|
35
|
+
'.cjs'
|
|
36
|
+
] }: ConvertOptions);
|
|
14
37
|
export default convert;
|
package/lib/bin/convert.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{readFile as e,writeFile as t}from"node:fs/promises";import o from"node:path";import{createDir as s,ink as a,println as i,scanFolderSync as l,updateFile as n}from"@moneko/utils";import{transformFile as c}from"@swc/core";function r(e,t,s){let a=t.split(o.sep),i=""===a[0]?a[1]:a[0],l=t.replace(i,""),n=o.join(e,l);return s?n.replace(o.extname(n),s):n}let m={".ts":".js",".tsx":".js",".mts":".mjs",".cts":".cjs",".js":".js",".jsx":".js",".mjs":".mjs",".cjs":".cjs"},p={format:{comments:!1},ecma:2015,compress:{drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1,top_retain:[],keep_infinity:!0},mangle:!0};async function d({ignore:d=[],quiet:f=!0,copy:j=!0,outDir:_,outputExtension:u,inputDir:h,options:$,extensions:g=[".ts",".js",".tsx",".jsx",".mts",".mjs",".cts",".cjs"]}){let w=process.hrtime(),x={duration:0,compiled:[],copied:[],failed:[]},y=l(h,["^.*"]).map(e=>o.normalize(e)),k=[],b=[];y.forEach(e=>{!(/\.DS_Store/.test(e)||d.some(t=>t.test(e)))&&(g.includes(o.extname(e))?k.push(e):j&&b.push(e))});let v=k.map(async e=>{try{let t=u||m[o.extname(e)],{code:s,map:a,output:i}=await c(e,{...$,jsc:{...$.jsc,minify:{...p,...$.jsc?.minify}}}),l=r(_,e,t);if(await n(l,s),a&&await n(`${l}.map`,a),x.compiled.push(`${e} -> ${l}`),i){let t=JSON.parse(i);if(t.__swc_isolated_declarations__){let s=o.extname(e),a=r(_,e.replace(s,`.d${s}`));await n(a,t.__swc_isolated_declarations__)}}}catch(t){x.failed.push(`Error converting ${e}: ${t}`)}}).concat(b.map(async a=>{let i=r(_,a);try{let l=await e(a);s(o.dirname(i)),await t(i,l),x.copied.push(`${a} -> ${i}`)}catch(e){x.failed.push(`Error copying ${a} -> ${i}: ${e}`)}}));await Promise.all(v);let E=process.hrtime(w);return x.duration=1e3*E[0]+E[1]/1e6,f&&i([a("✨ 编译成功!🎉","82",{bold:!0}),a(`⏱️ 总耗时:${x.duration.toFixed(3)} ms`,"117"),x.compiled.length&&a(`📄 编译文件:${x.compiled.length} 个`,"213"),x.copied.length&&a(`📋 复制文件:${x.copied.length} 个`,"226"),x.failed.length&&a(`❌ 编译失败:${x.failed.length} 个`,"203")].filter(Boolean).join("\n- ")),x}export default d;
|
package/lib/bin/index.d.mts
CHANGED
|
File without changes
|
package/lib/bin/index.mjs
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.26.13-beta.
|
|
3
|
+
"version": "3.26.13-beta.7",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"@moneko/stylelint": "1.0.1",
|
|
24
24
|
"@moneko/transform-imports": "0.6.1",
|
|
25
25
|
"@moneko/utils": "0.1.19",
|
|
26
|
-
"@swc/cli": "0.5.2",
|
|
27
26
|
"@swc/core": "1.6.13",
|
|
28
27
|
"browserslist": "4.24.3",
|
|
29
28
|
"chokidar": "4.0.2",
|