@modern-js/module-tools 2.15.0 → 2.16.0-beta.0
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/postcss-custom-properties/index.js +1 -1
- package/compiled/postcss-custom-properties/package.json +1 -1
- package/dist/build.js +23 -66
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +114 -170
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +23 -65
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +83 -164
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/index.js +15 -28
- package/dist/builder/dts/index.js.map +1 -1
- package/dist/builder/dts/rollup.js +46 -120
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +82 -141
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +34 -85
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +40 -93
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +35 -84
- package/dist/cli.js.map +1 -1
- package/dist/command.js +56 -136
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +13 -42
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/legacySchema.js +96 -52
- package/dist/config/legacySchema.js.map +1 -1
- package/dist/config/normalize.js +73 -149
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/schema.d.ts +36 -0
- package/dist/config/schema.js +118 -56
- package/dist/config/schema.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +152 -203
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/build.js +15 -27
- package/dist/constants/build.js.map +1 -1
- package/dist/constants/buildPresets.js +71 -84
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/constants/colors.js +28 -30
- package/dist/constants/colors.js.map +1 -1
- package/dist/constants/dts.js +13 -28
- package/dist/constants/dts.js.map +1 -1
- package/dist/constants/file.js +27 -30
- package/dist/constants/file.js.map +1 -1
- package/dist/constants/legacyBuildPresets.js +33 -49
- package/dist/constants/legacyBuildPresets.js.map +1 -1
- package/dist/constants/log.js +15 -33
- package/dist/constants/log.js.map +1 -1
- package/dist/dev.js +45 -91
- package/dist/dev.js.map +1 -1
- package/dist/error.js +37 -54
- package/dist/error.js.map +1 -1
- package/dist/hooks/build.js +22 -35
- package/dist/hooks/build.js.map +1 -1
- package/dist/hooks/dev.js +15 -33
- package/dist/hooks/dev.js.map +1 -1
- package/dist/hooks/index.js +15 -42
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/misc.js +10 -28
- package/dist/hooks/misc.js.map +1 -1
- package/dist/index.js +21 -35
- package/dist/index.js.map +1 -1
- package/dist/locale/en.d.ts +7 -2
- package/dist/locale/en.js +25 -32
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.d.ts +14 -4
- package/dist/locale/index.js +18 -31
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/zh.d.ts +7 -2
- package/dist/locale/zh.js +25 -32
- package/dist/locale/zh.js.map +1 -1
- package/dist/plugins.js +16 -39
- package/dist/plugins.js.map +1 -1
- package/dist/types/color.js +4 -15
- package/dist/types/color.js.map +1 -1
- package/dist/types/command.js +4 -15
- package/dist/types/command.js.map +1 -1
- package/dist/types/config/index.d.ts +6 -0
- package/dist/types/config/index.js +6 -17
- package/dist/types/config/index.js.map +1 -1
- package/dist/types/config/style.js +4 -15
- package/dist/types/config/style.js.map +1 -1
- package/dist/types/context.js +4 -15
- package/dist/types/context.js.map +1 -1
- package/dist/types/copy.js +4 -15
- package/dist/types/copy.js.map +1 -1
- package/dist/types/dts.js +4 -15
- package/dist/types/dts.js.map +1 -1
- package/dist/types/hooks.js +4 -15
- package/dist/types/hooks.js.map +1 -1
- package/dist/types/index.js +11 -22
- package/dist/types/index.js.map +1 -1
- package/dist/types/legacyConfig/index.js +4 -15
- package/dist/types/legacyConfig/index.js.map +1 -1
- package/dist/types/legacyConfig/output.js +4 -15
- package/dist/types/legacyConfig/output.js.map +1 -1
- package/dist/types/legacyConfig/source.js +4 -15
- package/dist/types/legacyConfig/source.js.map +1 -1
- package/dist/types/legacyConfig/tools.js +4 -15
- package/dist/types/legacyConfig/tools.js.map +1 -1
- package/dist/types/utils.js +4 -17
- package/dist/utils/builder.d.ts +20 -2
- package/dist/utils/builder.js +81 -68
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +10 -44
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +108 -144
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +16 -59
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +69 -146
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +44 -87
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +15 -60
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +27 -67
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +14 -61
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +14 -61
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +13 -59
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +57 -105
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +54 -106
- package/dist/utils/style.js.map +1 -1
- package/dist/utils/tspathsTransform.js +44 -81
- package/dist/utils/tspathsTransform.js.map +1 -1
- package/package.json +11 -10
- package/scripts/debug-mode.js +23 -21
- package/dist/types/utils.js.map +0 -1
package/dist/utils/print.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":"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","names":["bundleFiles","bundlelessFiles","addOutputChunk","addRollupChunk","addDtsFiles","printFileSize","printSucceed","outputChunk","appDirectory","isBundle","files","Array","from","map","val","path","chunk","name","relative","size","contents","length","push","rollupOutput","distDir","output","o","resolve","fileName","code","fastGlob","slash","stats","file","printBundlelessInfo","printBundleFiles","totalDuration","time","chalk","cyan","logger","info","buildSuccessText","prettyBytes","bytes","unit","exp","Math","floor","log","pow","toFixed","longestFileLength","reduce","max","str","reportFile1LineText","headerRow","repeat","reportFile2LineText","bold","green","forEach","infoRow","count","totalSize","total"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/print.ts"],"sourcesContent":["import { relative, resolve } from 'path';\nimport type { ILibuilder } from '@modern-js/libuild';\nimport { chalk, logger } from '@modern-js/utils';\nimport type {\n RollupOutput,\n OutputChunk,\n} from '../../compiled/rollup/types/rollup';\nimport {\n buildSuccessText,\n reportFile1LineText,\n reportFile2LineText,\n} from '../constants/log';\n\ntype Files = {\n name: string;\n size: number;\n};\n\nexport const bundleFiles: Files[] = [];\n\nexport const bundlelessFiles: Files[] = [];\n\nexport const addOutputChunk = (\n outputChunk: ILibuilder['outputChunk'],\n appDirectory: string,\n isBundle: boolean,\n) => {\n const files = Array.from(outputChunk).map(val => {\n const [path, chunk] = val;\n return {\n name: relative(appDirectory, path),\n size: chunk.contents.length,\n };\n });\n if (isBundle) {\n bundleFiles.push(...files);\n } else {\n bundlelessFiles.push(...files);\n }\n};\n\nexport const addRollupChunk = (\n rollupOutput: RollupOutput,\n appDirectory: string,\n distDir: string,\n) => {\n const { output } = rollupOutput;\n bundleFiles.push(\n ...output.map(o => {\n return {\n name: relative(appDirectory, resolve(distDir, o.fileName)),\n // only d.ts, is outputChunk not outputAsset\n size: (o as OutputChunk).code.length,\n };\n }),\n );\n};\n\nexport const addDtsFiles = async (distDir: string, appDirectory: string) => {\n const { fastGlob, slash } = await import('@modern-js/utils');\n const files = await fastGlob(`${slash(distDir)}**/*.d.ts`, {\n stats: true,\n });\n bundlelessFiles.push(\n ...files.map(file => {\n return {\n name: relative(appDirectory, file.path),\n size: file.stats.size,\n };\n }),\n );\n};\n\nexport const printFileSize = () => {\n printBundlelessInfo();\n printBundleFiles();\n};\n\nexport const printSucceed = (totalDuration: number) => {\n const time = chalk.cyan(`${totalDuration / 1000}s`);\n logger.info(`${buildSuccessText} in ${time}`);\n};\n\nconst prettyBytes = (bytes: number) => {\n if (bytes === 0) {\n return '0 B';\n }\n const unit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const exp = Math.floor(Math.log(bytes) / Math.log(1024));\n return `${(bytes / Math.pow(1024, exp)).toFixed(2)} ${unit[exp]}`;\n};\n\nconst printBundleFiles = () => {\n if (bundleFiles.length === 0) {\n return;\n }\n const longestFileLength = bundleFiles.reduce(\n (max, str) => Math.max(max, str.name.length),\n reportFile1LineText.length,\n );\n\n logger.info(`Bundle generated ${bundleFiles.length} files\\n`);\n\n const headerRow =\n reportFile1LineText +\n ' '.repeat(longestFileLength - 10) +\n reportFile2LineText;\n logger.log(chalk.bold(chalk.green(headerRow)));\n\n bundleFiles.forEach(({ name, size }) => {\n const infoRow = `${name}${' '.repeat(\n longestFileLength - name.length + 2,\n )}${prettyBytes(size)}`;\n logger.log(infoRow);\n });\n};\n\nconst printBundlelessInfo = () => {\n if (bundlelessFiles.length === 0) {\n return;\n }\n\n const count = bundlelessFiles.length;\n const totalSize = bundlelessFiles.reduce((total, file) => {\n return total + file.size;\n }, 0);\n const info = `Bundleless generated ${count} files, the total size is ${chalk.cyan(\n prettyBytes(totalSize),\n )}`;\n logger.info(info);\n};\n"]}
|
package/dist/utils/style.js
CHANGED
|
@@ -1,87 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
var style_exports = {};
|
|
49
|
-
__export(style_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
50
13
|
getLessConfig: () => getLessConfig,
|
|
51
|
-
getPostcssConfig: () => getPostcssConfig,
|
|
52
14
|
getSassConfig: () => getSassConfig,
|
|
15
|
+
getPostcssConfig: () => getPostcssConfig,
|
|
53
16
|
getStyleConfig: () => getStyleConfig
|
|
54
17
|
});
|
|
55
|
-
|
|
56
|
-
const getLessConfig = (config) =>
|
|
57
|
-
var
|
|
58
|
-
const { applyOptionsChain } =
|
|
59
|
-
const { getCompiledPath } =
|
|
60
|
-
const mergedOptions = applyOptionsChain(
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
implementation: yield getCompiledPath("less")
|
|
18
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
19
|
+
const getLessConfig = async (config) => {
|
|
20
|
+
var _config_style;
|
|
21
|
+
const { applyOptionsChain } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
22
|
+
const { getCompiledPath } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./path")));
|
|
23
|
+
const mergedOptions = applyOptionsChain({
|
|
24
|
+
lessOptions: {
|
|
25
|
+
javascriptEnabled: true
|
|
64
26
|
},
|
|
65
|
-
|
|
66
|
-
);
|
|
27
|
+
implementation: await getCompiledPath("less")
|
|
28
|
+
}, (config === null || config === void 0 ? void 0 : (_config_style = config.style) === null || _config_style === void 0 ? void 0 : _config_style.less) || {});
|
|
67
29
|
return mergedOptions;
|
|
68
|
-
}
|
|
69
|
-
const getSassConfig = (config) =>
|
|
70
|
-
var
|
|
71
|
-
const { applyOptionsChain } =
|
|
72
|
-
const { getCompiledPath } =
|
|
73
|
-
const mergedOptions = applyOptionsChain(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
((_a = config == null ? void 0 : config.style) == null ? void 0 : _a.sass) || {}
|
|
78
|
-
);
|
|
30
|
+
};
|
|
31
|
+
const getSassConfig = async (config) => {
|
|
32
|
+
var _config_style;
|
|
33
|
+
const { applyOptionsChain } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
34
|
+
const { getCompiledPath } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./path")));
|
|
35
|
+
const mergedOptions = applyOptionsChain({
|
|
36
|
+
implementation: await getCompiledPath("sass")
|
|
37
|
+
}, (config === null || config === void 0 ? void 0 : (_config_style = config.style) === null || _config_style === void 0 ? void 0 : _config_style.sass) || {});
|
|
79
38
|
return mergedOptions;
|
|
80
|
-
}
|
|
81
|
-
const getPostcssConfig = (config) =>
|
|
82
|
-
var
|
|
83
|
-
const { applyOptionsChain } =
|
|
84
|
-
const { getCompiledPath } =
|
|
39
|
+
};
|
|
40
|
+
const getPostcssConfig = async (config) => {
|
|
41
|
+
var _config_style;
|
|
42
|
+
const { applyOptionsChain } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
43
|
+
const { getCompiledPath } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./path")));
|
|
85
44
|
const extraPlugins = [];
|
|
86
45
|
const utils = {
|
|
87
46
|
addPlugins(plugins) {
|
|
@@ -92,44 +51,33 @@ const getPostcssConfig = (config) => __async(void 0, null, function* () {
|
|
|
92
51
|
}
|
|
93
52
|
}
|
|
94
53
|
};
|
|
95
|
-
const mergedConfig = applyOptionsChain(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
((_a = config == null ? void 0 : config.style) == null ? void 0 : _a.postcss) || {},
|
|
110
|
-
utils
|
|
111
|
-
);
|
|
54
|
+
const mergedConfig = applyOptionsChain({
|
|
55
|
+
// TODO: when schema support redefine
|
|
56
|
+
// $$tools: 'module-tools',
|
|
57
|
+
plugins: [
|
|
58
|
+
require(await getCompiledPath("postcss-flexbugs-fixes")),
|
|
59
|
+
require(await getCompiledPath("postcss-custom-properties")),
|
|
60
|
+
require(await getCompiledPath("postcss-initial")),
|
|
61
|
+
require(await getCompiledPath("postcss-page-break")),
|
|
62
|
+
require(await getCompiledPath("postcss-font-variant")),
|
|
63
|
+
require(await getCompiledPath("postcss-media-minmax")),
|
|
64
|
+
require(await getCompiledPath("postcss-nesting"))
|
|
65
|
+
].filter(Boolean)
|
|
66
|
+
}, (config === null || config === void 0 ? void 0 : (_config_style = config.style) === null || _config_style === void 0 ? void 0 : _config_style.postcss) || {}, utils);
|
|
112
67
|
if (extraPlugins.length) {
|
|
113
68
|
mergedConfig.plugins.push(...extraPlugins);
|
|
114
69
|
}
|
|
115
70
|
return mergedConfig;
|
|
116
|
-
}
|
|
117
|
-
const getStyleConfig = (config) =>
|
|
118
|
-
const postcssConfig =
|
|
119
|
-
const lessConfig =
|
|
120
|
-
const sassConfig =
|
|
71
|
+
};
|
|
72
|
+
const getStyleConfig = async (config) => {
|
|
73
|
+
const postcssConfig = await getPostcssConfig(config);
|
|
74
|
+
const lessConfig = await getLessConfig(config);
|
|
75
|
+
const sassConfig = await getSassConfig(config);
|
|
121
76
|
return {
|
|
122
77
|
less: lessConfig,
|
|
123
78
|
sass: sassConfig,
|
|
124
79
|
postcss: postcssConfig
|
|
125
80
|
};
|
|
126
|
-
}
|
|
127
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
-
0 && (module.exports = {
|
|
129
|
-
getLessConfig,
|
|
130
|
-
getPostcssConfig,
|
|
131
|
-
getSassConfig,
|
|
132
|
-
getStyleConfig
|
|
133
|
-
});
|
|
81
|
+
};
|
|
134
82
|
|
|
135
83
|
//# sourceMappingURL=style.js.map
|
package/dist/utils/style.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA,eAAa,MAAbA;EAeAC,eAAa,MAAbA;EAcAC,kBAAgB,MAAhBA;EA0CAC,gBAAc,MAAdA;;;AAvEN,MAAMH,gBAAgB,OAAOI,WAAmC;MASnEA;AARF,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,QAAM,EAAEC,gBAAe,IAAK,MAAM,iFAAO;AAEzC,QAAMC,gBAAgBF,kBACpB;IACEG,aAAa;MAAEC,mBAAmB;IAAK;IACvCC,gBAAgB,MAAMJ,gBAAgB;EACxC,IACAF,wEAAQO,WAAK,QAAbP,kDAAeQ,SAAQ,CAAC;AAG1B,SAAOL;AACT;AAEO,MAAMN,gBAAgB,OAAOG,WAAmC;MAQnEA;AAPF,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,QAAM,EAAEC,gBAAe,IAAK,MAAM,iFAAO;AAEzC,QAAMC,gBAAgBF,kBACpB;IACEK,gBAAgB,MAAMJ,gBAAgB;EACxC,IACAF,wEAAQO,WAAK,QAAbP,kDAAeS,SAAQ,CAAC;AAG1B,SAAON;AACT;AAEO,MAAML,mBAAmB,OAAOE,WAAmC;MAgCtEA;AA/BF,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,QAAM,EAAEC,gBAAe,IAAK,MAAM,iFAAO;AACzC,QAAMQ,eAAiC;AAEvC,QAAMC,QAAQ;IACZC,WAAWC,SAA4C;AACrD,UAAIC,MAAMC,QAAQF,UAAU;AAC1BH,qBAAaM,KAAI,GAAIH;MACvB,OAAO;AACLH,qBAAaM,KAAKH;MACpB;IACF;EACF;AAEA,QAAMI,eAAehB,kBAInB;;;IAGEY,SAAS;MACPK,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BiB,OAAOC;EACX,IACApB,wEAAQO,WAAK,QAAbP,kDAAeqB,YAAW,CAAC,GAC3BV;AAEF,MAAID,aAAaY,QAAQ;AACvBL,iBAAaJ,QAASG,KAAI,GAAIN;EAChC;AAEA,SAAOO;AACT;AAEO,MAAMlB,iBAAiB,OAAOC,WAAmC;AACtE,QAAMuB,gBAAgB,MAAMzB,iBAAiBE;AAC7C,QAAMwB,aAAa,MAAM5B,cAAcI;AACvC,QAAMyB,aAAa,MAAM5B,cAAcG;AACvC,SAAO;IACLQ,MAAMgB;IACNf,MAAMgB;IACNJ,SAASE;EACX;AACF;","names":["getLessConfig","getSassConfig","getPostcssConfig","getStyleConfig","config","applyOptionsChain","getCompiledPath","mergedOptions","lessOptions","javascriptEnabled","implementation","style","less","sass","extraPlugins","utils","addPlugins","plugins","Array","isArray","push","mergedConfig","require","filter","Boolean","postcss","length","postcssConfig","lessConfig","sassConfig"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/style.ts"],"sourcesContent":["import type { AcceptedPlugin } from 'postcss';\nimport type { PostcssOptions } from '@modern-js/libuild';\nimport type {\n PartialBaseBuildConfig,\n PostCSSConfigUtils,\n LessOptions,\n SassOptions,\n} from '../types';\n\nexport const getLessConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n\n const mergedOptions = applyOptionsChain<LessOptions, never>(\n {\n lessOptions: { javascriptEnabled: true },\n implementation: await getCompiledPath('less'),\n },\n config?.style?.less || {},\n );\n\n return mergedOptions;\n};\n\nexport const getSassConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n\n const mergedOptions = applyOptionsChain<SassOptions, never>(\n {\n implementation: await getCompiledPath('sass'),\n },\n config?.style?.sass || {},\n );\n\n return mergedOptions;\n};\n\nexport const getPostcssConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n const extraPlugins: AcceptedPlugin[] = [];\n\n const utils = {\n addPlugins(plugins: AcceptedPlugin | AcceptedPlugin[]) {\n if (Array.isArray(plugins)) {\n extraPlugins.push(...plugins);\n } else {\n extraPlugins.push(plugins);\n }\n },\n };\n\n const mergedConfig = applyOptionsChain<\n PostcssOptions & { $$tools?: string },\n PostCSSConfigUtils\n >(\n {\n // TODO: when schema support redefine\n // $$tools: 'module-tools',\n plugins: [\n require(await getCompiledPath('postcss-flexbugs-fixes')),\n require(await getCompiledPath('postcss-custom-properties')),\n require(await getCompiledPath('postcss-initial')),\n require(await getCompiledPath('postcss-page-break')),\n require(await getCompiledPath('postcss-font-variant')),\n require(await getCompiledPath('postcss-media-minmax')),\n require(await getCompiledPath('postcss-nesting')),\n ].filter(Boolean),\n },\n config?.style?.postcss || {},\n utils,\n );\n if (extraPlugins.length) {\n mergedConfig.plugins!.push(...extraPlugins);\n }\n\n return mergedConfig;\n};\n\nexport const getStyleConfig = async (config: PartialBaseBuildConfig) => {\n const postcssConfig = await getPostcssConfig(config);\n const lessConfig = await getLessConfig(config);\n const sassConfig = await getSassConfig(config);\n return {\n less: lessConfig,\n sass: sassConfig,\n postcss: postcssConfig,\n };\n};\n"]}
|
|
@@ -1,76 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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 tspathsTransform_exports = {};
|
|
29
|
-
__export(tspathsTransform_exports, {
|
|
30
|
-
transformDtsAlias: () => transformDtsAlias
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
5
|
+
Object.defineProperty(exports, "transformDtsAlias", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => transformDtsAlias
|
|
8
|
+
});
|
|
9
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
11
|
+
const _path = /* @__PURE__ */ _interop_require_wildcard._(require("path"));
|
|
12
|
+
const _tsconfigpaths = require("@modern-js/utils/tsconfig-paths");
|
|
13
|
+
const _utils = require("@modern-js/utils");
|
|
14
|
+
const _parser = /* @__PURE__ */ _interop_require_wildcard._(require("../../compiled/@babel/parser"));
|
|
15
|
+
const _generator = /* @__PURE__ */ _interop_require_default._(require("../../compiled/@babel/generator"));
|
|
16
|
+
const _types = /* @__PURE__ */ _interop_require_wildcard._(require("../../compiled/@babel/types"));
|
|
17
|
+
const _traverse = /* @__PURE__ */ _interop_require_default._(require("../../compiled/@babel/traverse"));
|
|
18
|
+
const _file = require("../constants/file");
|
|
41
19
|
function mapPathString(nodePath, { filename, baseUrl, paths }) {
|
|
42
|
-
if (!
|
|
20
|
+
if (!_types.isStringLiteral(nodePath)) {
|
|
43
21
|
return;
|
|
44
22
|
}
|
|
45
23
|
const sourcePath = nodePath.node.value;
|
|
46
24
|
const currentFile = filename;
|
|
47
|
-
const matchPath = (0,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(packageJsonPath)
|
|
55
|
-
|
|
56
|
-
return void 0;
|
|
57
|
-
}
|
|
58
|
-
return import_utils.fs.readJSONSync(packageJsonPath);
|
|
59
|
-
},
|
|
60
|
-
(filePath) => import_utils.fs.existsSync(filePath),
|
|
61
|
-
import_file.dtsAliasExts
|
|
62
|
-
);
|
|
25
|
+
const matchPath = (0, _tsconfigpaths.createMatchPath)(baseUrl, paths, [
|
|
26
|
+
"index"
|
|
27
|
+
]);
|
|
28
|
+
const result = matchPath(sourcePath, (packageJsonPath) => {
|
|
29
|
+
if (!_utils.fs.existsSync(packageJsonPath)) {
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
return _utils.fs.readJSONSync(packageJsonPath);
|
|
33
|
+
}, (filePath) => _utils.fs.existsSync(filePath), _file.dtsAliasExts);
|
|
63
34
|
if (result) {
|
|
64
|
-
const relativePath =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
);
|
|
68
|
-
const fileName = path.basename(result);
|
|
69
|
-
const filePath = path.normalize(
|
|
70
|
-
`${relativePath.length === 0 ? "." : relativePath}/${fileName}`
|
|
71
|
-
);
|
|
35
|
+
const relativePath = _path.relative(_path.dirname(currentFile), _path.dirname(result));
|
|
36
|
+
const fileName = _path.basename(result);
|
|
37
|
+
const filePath = _path.normalize(`${relativePath.length === 0 ? "." : relativePath}/${fileName}`);
|
|
72
38
|
const replaceString = filePath.startsWith(".") ? filePath : `./${filePath}`;
|
|
73
|
-
nodePath.replaceWith(
|
|
39
|
+
nodePath.replaceWith(_types.stringLiteral(replaceString));
|
|
74
40
|
}
|
|
75
41
|
}
|
|
76
42
|
const transformImport = (option) => (nodePath) => {
|
|
@@ -79,19 +45,16 @@ const transformImport = (option) => (nodePath) => {
|
|
|
79
45
|
const transformExport = (option) => (nodePath) => {
|
|
80
46
|
mapPathString(nodePath.get("source"), option);
|
|
81
47
|
};
|
|
82
|
-
const transformSingleFileAlias = ({
|
|
83
|
-
filename,
|
|
84
|
-
|
|
85
|
-
paths
|
|
86
|
-
}) => {
|
|
87
|
-
const sourceCode = import_utils.fs.readFileSync(filename, "utf-8");
|
|
88
|
-
const ast = parser.parse(sourceCode, {
|
|
48
|
+
const transformSingleFileAlias = ({ filename, baseUrl, paths }) => {
|
|
49
|
+
const sourceCode = _utils.fs.readFileSync(filename, "utf-8");
|
|
50
|
+
const ast = _parser.parse(sourceCode, {
|
|
89
51
|
sourceType: "module",
|
|
90
52
|
errorRecovery: true,
|
|
91
|
-
|
|
92
|
-
|
|
53
|
+
plugins: [
|
|
54
|
+
"typescript"
|
|
55
|
+
]
|
|
93
56
|
});
|
|
94
|
-
(0,
|
|
57
|
+
(0, _traverse.default)(ast, {
|
|
95
58
|
// d.ts file content not have callExpression which can be parsed;
|
|
96
59
|
// CallExpression: transformCall({ filename, baseUrl, paths }) as any,
|
|
97
60
|
ImportDeclaration: transformImport({
|
|
@@ -105,7 +68,7 @@ const transformSingleFileAlias = ({
|
|
|
105
68
|
paths
|
|
106
69
|
})
|
|
107
70
|
});
|
|
108
|
-
return (0,
|
|
71
|
+
return (0, _generator.default)(ast).code;
|
|
109
72
|
};
|
|
110
73
|
const transformDtsAlias = (option) => {
|
|
111
74
|
const { filenames = [], baseUrl, paths } = option;
|
|
@@ -113,14 +76,14 @@ const transformDtsAlias = (option) => {
|
|
|
113
76
|
for (const filename of filenames) {
|
|
114
77
|
transformResult.push({
|
|
115
78
|
path: filename,
|
|
116
|
-
content: transformSingleFileAlias({
|
|
79
|
+
content: transformSingleFileAlias({
|
|
80
|
+
filename,
|
|
81
|
+
baseUrl,
|
|
82
|
+
paths
|
|
83
|
+
})
|
|
117
84
|
});
|
|
118
85
|
}
|
|
119
86
|
return transformResult;
|
|
120
87
|
};
|
|
121
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
-
0 && (module.exports = {
|
|
123
|
-
transformDtsAlias
|
|
124
|
-
});
|
|
125
88
|
|
|
126
89
|
//# sourceMappingURL=tspathsTransform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAmHaA;;aAAAA;;;;kEAnHS;+BACU;uBACb;oEACK;sEACF;mEACH;qEACgB;sBACN;AAU7B,SAASC,cACPC,UACA,EAAEC,UAAUC,SAASC,MAAK,GAC1B;AACA,MAAI,CAACC,OAAEC,gBAAgBL,WAAW;AAChC;EACF;AAEA,QAAMM,aAAaN,SAASO,KAAKC;AACjC,QAAMC,cAAcR;AACpB,QAAMS,aAAYC,mCAChBT,SACAC,OACA;IAAC;GAAQ;AAEX,QAAMS,SAASF,UACbJ,YACAO,qBAAmB;AACjB,QAAI,CAACC,UAAGC,WAAWF,kBAAkB;AACnC,aAAOG;IACT;AACA,WAAOF,UAAGG,aAAaJ;EACzB,GACAK,cAAYJ,UAAGC,WAAWG,WAC1BC,kBAAY;AAEd,MAAIP,QAAQ;AACV,UAAMQ,eAAeC,MAAKC,SACxBD,MAAKE,QAAQd,cACbY,MAAKE,QAAQX;AAEf,UAAMY,WAAWH,MAAKI,SAASb;AAE/B,UAAMM,WAAWG,MAAKK,UACpB,GAAGN,aAAaO,WAAW,IAAI,MAAMP,gBAAgBI,UAAU;AAEjE,UAAMI,gBAAgBV,SAASW,WAAW,OAAOX,WAAW,KAAKA;AACjElB,aAAS8B,YAAY1B,OAAE2B,cAAcH;EACvC;AACF;AAgBA,MAAMI,kBACJ,CAACC,WAA4B,CAACjC,aAA4C;AACxED,gBAAcC,SAASkC,IAAI,WAAWD;AACxC;AAEF,MAAME,kBACJ,CAACF,WAA4B,CAACjC,aAA4C;AACxED,gBAAcC,SAASkC,IAAI,WAAwCD;AACrE;AAEF,MAAMG,2BAA2B,CAAC,EAChCnC,UACAC,SACAC,MAAK,MACgB;AACrB,QAAMkC,aAAavB,UAAGwB,aAAarC,UAAU;AAC7C,QAAMsC,MAAMC,QAAOC,MAAMJ,YAAY;IACnCK,YAAY;IACZC,eAAe;IACfC,SAAS;MAAC;;EACZ;AACAC,yBAASN,KAAK;;;IAGZO,mBAAmBd,gBAAgB;MACjC/B;MACAC;MACAC;IACF;IACA4C,mBAAmBZ,gBAAgB;MACjClC;MACAC;MACAC;IACF;EACF;AACA,UAAO6C,uBAAUT,KAAKU;AACxB;AAOO,MAAMnD,oBAAoB,CAACmC,WAAoC;AACpE,QAAM,EAAEiB,YAAY,IAAIhD,SAASC,MAAK,IAAK8B;AAC3C,QAAMkB,kBAAuD;AAC7D,aAAWlD,YAAYiD,WAAW;AAChCC,oBAAgBC,KAAK;MACnB/B,MAAMpB;MACNoD,SAASjB,yBAAyB;QAAEnC;QAAUC;QAASC;MAAM;IAC/D;EACF;AACA,SAAOgD;AACT;","names":["transformDtsAlias","mapPathString","nodePath","filename","baseUrl","paths","t","isStringLiteral","sourcePath","node","value","currentFile","matchPath","createMatchPath","result","packageJsonPath","fs","existsSync","undefined","readJSONSync","filePath","dtsAliasExts","relativePath","path","relative","dirname","fileName","basename","normalize","length","replaceString","startsWith","replaceWith","stringLiteral","transformImport","option","get","transformExport","transformSingleFileAlias","sourceCode","readFileSync","ast","parser","parse","sourceType","errorRecovery","plugins","traverse","ImportDeclaration","ExportDeclaration","generator","code","filenames","transformResult","push","content"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/tspathsTransform.ts"],"sourcesContent":["import * as path from 'path';\nimport { createMatchPath } from '@modern-js/utils/tsconfig-paths';\nimport { fs } from '@modern-js/utils';\nimport * as parser from '../../compiled/@babel/parser';\nimport generator from '../../compiled/@babel/generator';\nimport * as t from '../../compiled/@babel/types';\nimport traverse, { NodePath } from '../../compiled/@babel/traverse';\nimport { dtsAliasExts } from '../constants/file';\n// import { defaultTransformedFunctions } from '../constants/dts';\n// import { matchesPattern, isImportCall } from './dts';\n\nexport interface TransformOption {\n filename: string;\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\n\nfunction mapPathString(\n nodePath: NodePath<t.StringLiteral>,\n { filename, baseUrl, paths }: TransformOption,\n) {\n if (!t.isStringLiteral(nodePath)) {\n return;\n }\n\n const sourcePath = nodePath.node.value;\n const currentFile = filename;\n const matchPath = createMatchPath(\n baseUrl,\n paths as { [key: string]: Array<string> },\n ['index'],\n );\n const result = matchPath(\n sourcePath,\n packageJsonPath => {\n if (!fs.existsSync(packageJsonPath)) {\n return undefined;\n }\n return fs.readJSONSync(packageJsonPath);\n },\n filePath => fs.existsSync(filePath),\n dtsAliasExts,\n );\n if (result) {\n const relativePath = path.relative(\n path.dirname(currentFile),\n path.dirname(result),\n );\n const fileName = path.basename(result);\n // 如果是同级文件,则返回的是 ''\n const filePath = path.normalize(\n `${relativePath.length === 0 ? '.' : relativePath}/${fileName}`,\n );\n const replaceString = filePath.startsWith('.') ? filePath : `./${filePath}`;\n nodePath.replaceWith(t.stringLiteral(replaceString));\n }\n}\n\n// const transformCall =\n// (option: TransformOption) => (nodePath: NodePath<t.CallExpression>) => {\n// const calleePath = nodePath.get('callee') as NodePath;\n// const isNormalCall = defaultTransformedFunctions.some(pattern =>\n// matchesPattern(calleePath, pattern),\n// );\n// if (isNormalCall || isImportCall(nodePath)) {\n// mapPathString(\n// nodePath.get('arguments.0') as NodePath<t.StringLiteral>,\n// option,\n// );\n// }\n// };\n\nconst transformImport =\n (option: TransformOption) => (nodePath: NodePath<t.ImportDeclaration>) => {\n mapPathString(nodePath.get('source'), option);\n };\n\nconst transformExport =\n (option: TransformOption) => (nodePath: NodePath<t.ExportDeclaration>) => {\n mapPathString(nodePath.get('source') as NodePath<t.StringLiteral>, option);\n };\n\nconst transformSingleFileAlias = ({\n filename,\n baseUrl,\n paths,\n}: TransformOption) => {\n const sourceCode = fs.readFileSync(filename, 'utf-8');\n const ast = parser.parse(sourceCode, {\n sourceType: 'module',\n errorRecovery: true, // 防止typescript不支持的语法出现而报错\n plugins: ['typescript'],\n });\n traverse(ast, {\n // d.ts file content not have callExpression which can be parsed;\n // CallExpression: transformCall({ filename, baseUrl, paths }) as any,\n ImportDeclaration: transformImport({\n filename,\n baseUrl,\n paths,\n }) as any,\n ExportDeclaration: transformExport({\n filename,\n baseUrl,\n paths,\n }) as any,\n });\n return generator(ast).code;\n};\n\ninterface TransformDtsAliasOption {\n filenames?: string[];\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\nexport const transformDtsAlias = (option: TransformDtsAliasOption) => {\n const { filenames = [], baseUrl, paths } = option;\n const transformResult: { path: string; content: string }[] = [];\n for (const filename of filenames) {\n transformResult.push({\n path: filename,\n content: transformSingleFileAlias({ filename, baseUrl, paths }),\n });\n }\n return transformResult;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"module-tools",
|
|
12
12
|
"lib-tools"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.16.0-beta.0",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js",
|
|
17
17
|
"modern-module": "./bin/modern.js"
|
|
@@ -36,17 +36,18 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@modern-js/libuild": "~0.
|
|
40
|
-
"@modern-js/libuild-plugin-svgr": "~0.
|
|
41
|
-
"@modern-js/libuild-plugin-swc": "~0.
|
|
39
|
+
"@modern-js/libuild": "~0.12.0",
|
|
40
|
+
"@modern-js/libuild-plugin-svgr": "~0.12.0",
|
|
41
|
+
"@modern-js/libuild-plugin-swc": "~0.12.0",
|
|
42
42
|
"postcss": "8.4.6",
|
|
43
|
+
"@swc/helpers": "0.5.0",
|
|
43
44
|
"@modern-js/core": "2.15.0",
|
|
44
45
|
"@modern-js/new-action": "2.15.0",
|
|
45
46
|
"@modern-js/plugin": "2.15.0",
|
|
46
47
|
"@modern-js/plugin-changeset": "2.15.0",
|
|
47
|
-
"@modern-js/plugin-i18n": "2.15.0",
|
|
48
|
-
"@modern-js/plugin-lint": "2.15.0",
|
|
49
48
|
"@modern-js/upgrade": "2.15.0",
|
|
49
|
+
"@modern-js/plugin-lint": "2.15.0",
|
|
50
|
+
"@modern-js/plugin-i18n": "2.15.0",
|
|
50
51
|
"@modern-js/utils": "2.15.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
@@ -60,8 +61,8 @@
|
|
|
60
61
|
"postcss-alias": "2.0.0",
|
|
61
62
|
"react": "17",
|
|
62
63
|
"typescript": "^4",
|
|
64
|
+
"@modern-js/self": "npm:@modern-js/module-tools@2.16.0-beta.0",
|
|
63
65
|
"@modern-js/builder-webpack-provider": "2.15.0",
|
|
64
|
-
"@modern-js/self": "npm:@modern-js/module-tools@2.15.0",
|
|
65
66
|
"@scripts/build": "2.15.0",
|
|
66
67
|
"@scripts/jest-config": "2.15.0"
|
|
67
68
|
},
|
|
@@ -79,9 +80,9 @@
|
|
|
79
80
|
},
|
|
80
81
|
"scripts": {
|
|
81
82
|
"build": "modern-lib build",
|
|
82
|
-
"dev": "modern-lib build --watch",
|
|
83
|
-
"test": "jest",
|
|
84
|
-
"test:update": "jest --updateSnapshot",
|
|
83
|
+
"dev": "npm run debug-mode && modern-lib build --watch",
|
|
84
|
+
"test": "npm run debug-mode off && jest",
|
|
85
|
+
"test:update": "npm run debug-mode off && jest --updateSnapshot",
|
|
85
86
|
"new": "modern-lib new",
|
|
86
87
|
"debug-mode": "node ./scripts/debug-mode.js"
|
|
87
88
|
}
|
package/scripts/debug-mode.js
CHANGED
|
@@ -17,33 +17,35 @@ const appDir = path.join(__dirname, '..');
|
|
|
17
17
|
const pkgPath = path.join(appDir, './package.json');
|
|
18
18
|
const tempPkgPath = path.join(appDir, 'temp-package.json');
|
|
19
19
|
|
|
20
|
+
console.debug('operation is', operation);
|
|
21
|
+
|
|
20
22
|
if (operation === ON) {
|
|
21
23
|
if (!fs.pathExistsSync(tempPkgPath)) {
|
|
22
24
|
fs.copyFileSync(pkgPath, tempPkgPath);
|
|
23
25
|
}
|
|
24
|
-
} else {
|
|
25
|
-
fs.copyFileSync(tempPkgPath, pkgPath);
|
|
26
|
-
fs.removeSync(tempPkgPath);
|
|
27
|
-
}
|
|
28
26
|
|
|
29
|
-
const pkgJson = require(pkgPath);
|
|
30
|
-
const originalExports = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
const debugExports = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
27
|
+
const pkgJson = require(pkgPath);
|
|
28
|
+
const originalExports = {
|
|
29
|
+
'.': './src/index.ts',
|
|
30
|
+
'./defineConfig': './src/config/defineConfig.ts',
|
|
31
|
+
};
|
|
32
|
+
const debugExports = {
|
|
33
|
+
'.': './dist/index.js',
|
|
34
|
+
'./defineConfig': './dist/config/defineConfig.js',
|
|
35
|
+
};
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
if (operation === ON) {
|
|
38
|
+
pkgJson.exports = debugExports;
|
|
39
|
+
} else {
|
|
40
|
+
pkgJson.exports = originalExports;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const output = fs.readFileSync(pkgPath, 'utf-8');
|
|
44
|
+
const indent = detectIndent(output);
|
|
45
|
+
fs.writeJSONSync(pkgPath, pkgJson, { spaces: indent.amount });
|
|
46
|
+
} else if (operation === OFF && fs.pathExistsSync(tempPkgPath)) {
|
|
47
|
+
fs.copyFileSync(tempPkgPath, pkgPath);
|
|
48
|
+
fs.removeSync(tempPkgPath);
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
const output = fs.readFileSync(pkgPath, 'utf-8');
|
|
47
|
-
const indent = detectIndent(output);
|
|
48
|
-
fs.writeJSONSync(pkgPath, pkgJson, { spaces: indent.amount });
|
|
49
51
|
/* eslint-enable no-console */
|
package/dist/types/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/utils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-types\nexport type DeepPartial<T> = T extends Function\n ? T\n : T extends Array<infer U>\n ? DeepPartialArray<U>\n : T extends object\n ? DeepPartialObject<T>\n : T | undefined;\n/** @private */\nexport type DeepPartialArray<T> = Array<DeepPartial<T>>;\n/** @private */\nexport type DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> };\n"]}
|