@modern-js/module-tools 2.10.1-beta.0 → 2.10.1-beta.1
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/build.js +29 -9
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +86 -48
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +29 -9
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +78 -39
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/rollup.js +61 -26
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +77 -37
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +36 -16
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +33 -13
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +45 -23
- package/dist/cli.js.map +1 -1
- package/dist/command.js +76 -39
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +18 -2
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/normalize.js +73 -45
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +130 -90
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/buildPresets.js +23 -14
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/dev.js +43 -19
- package/dist/dev.js.map +1 -1
- package/dist/error.js +2 -7
- package/dist/error.js.map +1 -1
- package/dist/hooks/index.js +15 -6
- package/dist/hooks/index.js.map +1 -1
- package/dist/utils/builder.js +27 -7
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +19 -3
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +83 -57
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +23 -3
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +64 -25
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +34 -14
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +23 -3
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +29 -9
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +23 -3
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +26 -6
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +23 -3
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +24 -4
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +52 -29
- package/dist/utils/style.js.map +1 -1
- package/lib/types.d.ts +0 -98
- package/package.json +5 -5
package/dist/utils/print.js
CHANGED
|
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve2, 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 ? resolve2(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
28
48
|
var print_exports = {};
|
|
29
49
|
__export(print_exports, {
|
|
30
50
|
addDtsFiles: () => addDtsFiles,
|
|
@@ -67,9 +87,9 @@ const addRollupChunk = (rollupOutput, appDirectory, distDir) => {
|
|
|
67
87
|
})
|
|
68
88
|
);
|
|
69
89
|
};
|
|
70
|
-
const addDtsFiles =
|
|
71
|
-
const { fastGlob, slash } =
|
|
72
|
-
const files =
|
|
90
|
+
const addDtsFiles = (distDir, appDirectory) => __async(void 0, null, function* () {
|
|
91
|
+
const { fastGlob, slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
92
|
+
const files = yield fastGlob(`${slash(distDir)}**/*.d.ts`, {
|
|
73
93
|
stats: true
|
|
74
94
|
});
|
|
75
95
|
bundlelessFiles.push(
|
|
@@ -80,7 +100,7 @@ const addDtsFiles = async (distDir, appDirectory) => {
|
|
|
80
100
|
};
|
|
81
101
|
})
|
|
82
102
|
);
|
|
83
|
-
};
|
|
103
|
+
});
|
|
84
104
|
const printFileSize = () => {
|
|
85
105
|
printBundlelessInfo();
|
|
86
106
|
printBundleFiles();
|
package/dist/utils/print.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAkC;AAElC,mBAA8B;AAK9B,iBAIO;AAOA,MAAM,cAAuB,CAAC;AAE9B,MAAM,kBAA2B,CAAC;AAElC,MAAM,iBAAiB,CAC5B,aACA,cACA,aACG;AACH,QAAM,QAAQ,MAAM,KAAK,WAAW,EAAE,IAAI,SAAO;AAC/C,UAAM,CAAC,MAAM,KAAK,IAAI;AACtB,WAAO;AAAA,MACL,UAAM,sBAAS,cAAc,IAAI;AAAA,MACjC,MAAM,MAAM,SAAS;AAAA,IACvB;AAAA,EACF,CAAC;AACD,MAAI,UAAU;AACZ,gBAAY,KAAK,GAAG,KAAK;AAAA,EAC3B,OAAO;AACL,oBAAgB,KAAK,GAAG,KAAK;AAAA,EAC/B;AACF;AAEO,MAAM,iBAAiB,CAC5B,cACA,cACA,YACG;AACH,QAAM,EAAE,OAAO,I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,KAAK,IAAI,KAAK,IAAI,KAAK,MAAM;AAAA,IAC3C,+BAAoB;AAAA,EACtB;AACA,QAAM,OAAO,oBAAoB,YAAY;AAAA;AAE7C,QAAM,YACJ,iCACA,IAAI,OAAO,oBAAoB,EAAE,IACjC;AAEF,sBAAO,KAAK,mBAAM,KAAK,mBAAM,KAAK,IAAI,CAAC,CAAC;AACxC,sBAAO,IAAI,mBAAM,KAAK,mBAAM,MAAM,SAAS,CAAC,CAAC;AAE7C,cAAY,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM;AACtC,UAAM,UAAU,GAAG,OAAO,IAAI;AAAA,MAC5B,oBAAoB,KAAK,SAAS;AAAA,IACpC,IAAI,YAAY,IAAI;AACpB,wBAAO,IAAI,OAAO;AAAA,EACpB,CAAC;AACH;AAEA,MAAM,sBAAsB,MAAM;AAChC,MAAI,gBAAgB,WAAW,GAAG;AAChC;AAAA,EACF;AAEA,QAAM,QAAQ,gBAAgB;AAC9B,QAAM,YAAY,gBAAgB,OAAO,CAAC,OAAO,SAAS;AACxD,WAAO,QAAQ,KAAK;AAAA,EACtB,GAAG,CAAC;AACJ,QAAM,OAAO,wBAAwB,kCAAkC;AAAA,IACrE;AAAA,EACF;AACA,sBAAO,KAAK,mBAAM,KAAK,mBAAM,KAAK,IAAI,CAAC,CAAC;AAC1C;;;;;;;;;;;","names":[],"sources":["../../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 logger.info(\n chalk.bold(chalk.blue(`${buildSuccessText}: ${totalDuration / 1000}s`)),\n );\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 const info = `Bundle generated ${bundleFiles.length} files\\n`;\n\n const headerRow =\n reportFile1LineText +\n ' '.repeat(longestFileLength - 10) +\n reportFile2LineText;\n\n logger.info(chalk.bold(chalk.blue(info)));\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 ${prettyBytes(\n totalSize,\n )}`;\n logger.info(chalk.bold(chalk.blue(info)));\n};\n"]}
|
package/dist/utils/style.js
CHANGED
|
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
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
|
+
};
|
|
28
48
|
var style_exports = {};
|
|
29
49
|
__export(style_exports, {
|
|
30
50
|
getLessConfig: () => getLessConfig,
|
|
@@ -33,32 +53,35 @@ __export(style_exports, {
|
|
|
33
53
|
getStyleConfig: () => getStyleConfig
|
|
34
54
|
});
|
|
35
55
|
module.exports = __toCommonJS(style_exports);
|
|
36
|
-
const getLessConfig =
|
|
37
|
-
|
|
38
|
-
const {
|
|
56
|
+
const getLessConfig = (config) => __async(void 0, null, function* () {
|
|
57
|
+
var _a;
|
|
58
|
+
const { applyOptionsChain } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
59
|
+
const { getCompiledPath } = yield Promise.resolve().then(() => __toESM(require("./path")));
|
|
39
60
|
const mergedOptions = applyOptionsChain(
|
|
40
61
|
{
|
|
41
62
|
lessOptions: { javascriptEnabled: true },
|
|
42
|
-
implementation:
|
|
63
|
+
implementation: yield getCompiledPath("less")
|
|
43
64
|
},
|
|
44
|
-
config
|
|
65
|
+
((_a = config == null ? void 0 : config.style) == null ? void 0 : _a.less) || {}
|
|
45
66
|
);
|
|
46
67
|
return mergedOptions;
|
|
47
|
-
};
|
|
48
|
-
const getSassConfig =
|
|
49
|
-
|
|
50
|
-
const {
|
|
68
|
+
});
|
|
69
|
+
const getSassConfig = (config) => __async(void 0, null, function* () {
|
|
70
|
+
var _a;
|
|
71
|
+
const { applyOptionsChain } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
72
|
+
const { getCompiledPath } = yield Promise.resolve().then(() => __toESM(require("./path")));
|
|
51
73
|
const mergedOptions = applyOptionsChain(
|
|
52
74
|
{
|
|
53
|
-
implementation:
|
|
75
|
+
implementation: yield getCompiledPath("sass")
|
|
54
76
|
},
|
|
55
|
-
config
|
|
77
|
+
((_a = config == null ? void 0 : config.style) == null ? void 0 : _a.sass) || {}
|
|
56
78
|
);
|
|
57
79
|
return mergedOptions;
|
|
58
|
-
};
|
|
59
|
-
const getPostcssConfig =
|
|
60
|
-
|
|
61
|
-
const {
|
|
80
|
+
});
|
|
81
|
+
const getPostcssConfig = (config) => __async(void 0, null, function* () {
|
|
82
|
+
var _a;
|
|
83
|
+
const { applyOptionsChain } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
84
|
+
const { getCompiledPath } = yield Promise.resolve().then(() => __toESM(require("./path")));
|
|
62
85
|
const extraPlugins = [];
|
|
63
86
|
const utils = {
|
|
64
87
|
addPlugins(plugins) {
|
|
@@ -74,33 +97,33 @@ const getPostcssConfig = async (config) => {
|
|
|
74
97
|
// TODO: when schema support redefine
|
|
75
98
|
// $$tools: 'module-tools',
|
|
76
99
|
plugins: [
|
|
77
|
-
require(
|
|
78
|
-
require(
|
|
79
|
-
require(
|
|
80
|
-
require(
|
|
81
|
-
require(
|
|
82
|
-
require(
|
|
83
|
-
require(
|
|
100
|
+
require(yield getCompiledPath("postcss-flexbugs-fixes")),
|
|
101
|
+
require(yield getCompiledPath("postcss-custom-properties")),
|
|
102
|
+
require(yield getCompiledPath("postcss-initial")),
|
|
103
|
+
require(yield getCompiledPath("postcss-page-break")),
|
|
104
|
+
require(yield getCompiledPath("postcss-font-variant")),
|
|
105
|
+
require(yield getCompiledPath("postcss-media-minmax")),
|
|
106
|
+
require(yield getCompiledPath("postcss-nesting"))
|
|
84
107
|
].filter(Boolean)
|
|
85
108
|
},
|
|
86
|
-
config
|
|
109
|
+
((_a = config == null ? void 0 : config.style) == null ? void 0 : _a.postcss) || {},
|
|
87
110
|
utils
|
|
88
111
|
);
|
|
89
112
|
if (extraPlugins.length) {
|
|
90
113
|
mergedConfig.plugins.push(...extraPlugins);
|
|
91
114
|
}
|
|
92
115
|
return mergedConfig;
|
|
93
|
-
};
|
|
94
|
-
const getStyleConfig =
|
|
95
|
-
const postcssConfig =
|
|
96
|
-
const lessConfig =
|
|
97
|
-
const sassConfig =
|
|
116
|
+
});
|
|
117
|
+
const getStyleConfig = (config) => __async(void 0, null, function* () {
|
|
118
|
+
const postcssConfig = yield getPostcssConfig(config);
|
|
119
|
+
const lessConfig = yield getLessConfig(config);
|
|
120
|
+
const sassConfig = yield getSassConfig(config);
|
|
98
121
|
return {
|
|
99
122
|
less: lessConfig,
|
|
100
123
|
sass: sassConfig,
|
|
101
124
|
postcss: postcssConfig
|
|
102
125
|
};
|
|
103
|
-
};
|
|
126
|
+
});
|
|
104
127
|
// Annotate the CommonJS export names for ESM import in node:
|
|
105
128
|
0 && (module.exports = {
|
|
106
129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AC3B;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe;AAAA,IAInB;AAAA;AAAA;AAAA,MAGE,SAAS;AAAA,QACP,QAAQ,MAAM,gBAAgB,wBAAwB,CAAC;AAAA,QACvD,QAAQ,MAAM,gBAAgB,2BAA2B,CAAC;AAAA,QAC1D,QAAQ,MAAM,gBAAgB,iBAAiB,CAAC;AAAA,QAChD,QAAQ,MAAM,gBAAgB,oBAAoB,CAAC;AAAA,QACnD,QAAQ,MAAM,gBAAgB,sBAAsB,CAAC;AAAA,QACrD,QAAQ,MAAM,gBAAgB,sBAAsB,CAAC;AAAA,QACrD,QAAQ,MAAM,gBAAgB,iBAAiB,CAAC;AAAA,MAClD,EAAE,OAAO,OAAO;AAAA,IAClB;AAAA,MACA,sCAAQ,UAAR,mBAAe,YAAW,CAAC;AAAA,IAC3B;AAAA,EACF;AACA,MAAI,aAAa,QAAQ;AACvB,iBAAa,QAAS,KAAK,GAAG,YAAY;AAAA,EAC5C;AAEA,SAAO;AACT;AAEO,MAAM,iBAAiB,CAAO,WAAmC;AACtE,QAAM,gBAAgB,MAAM,iBAAiB,MAAM;AACnD,QAAM,aAAa,MAAM,cAAc,MAAM;AAC7C,QAAM,aAAa,MAAM,cAAc,MAAM;AAC7C,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AACF;;;;;;;;","names":[],"sources":["../../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"]}
|
package/lib/types.d.ts
CHANGED
|
@@ -45,104 +45,6 @@ declare module '*.webp' {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
declare module '*.svg' {
|
|
48
|
-
import * as React from 'react';
|
|
49
|
-
|
|
50
|
-
export const ReactComponent: React.FunctionComponent<
|
|
51
|
-
React.SVGProps<SVGSVGElement>
|
|
52
|
-
>;
|
|
53
|
-
|
|
54
|
-
const src: string;
|
|
55
|
-
export default src;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
declare module '*.bmp?inline' {
|
|
59
|
-
const src: string;
|
|
60
|
-
export default src;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
declare module '*.gif?inline' {
|
|
64
|
-
const src: string;
|
|
65
|
-
export default src;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
declare module '*.jpg?inline' {
|
|
69
|
-
const src: string;
|
|
70
|
-
export default src;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
declare module '*.jpeg?inline' {
|
|
74
|
-
const src: string;
|
|
75
|
-
export default src;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
declare module '*.png?inline' {
|
|
79
|
-
const src: string;
|
|
80
|
-
export default src;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
declare module '*.ico?inline' {
|
|
84
|
-
const src: string;
|
|
85
|
-
export default src;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
declare module '*.webp?inline' {
|
|
89
|
-
const src: string;
|
|
90
|
-
export default src;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
declare module '*.svg?inline' {
|
|
94
|
-
import * as React from 'react';
|
|
95
|
-
|
|
96
|
-
export const ReactComponent: React.FunctionComponent<
|
|
97
|
-
React.SVGProps<SVGSVGElement>
|
|
98
|
-
>;
|
|
99
|
-
|
|
100
|
-
const src: string;
|
|
101
|
-
export default src;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
declare module '*.bmp?url' {
|
|
105
|
-
const src: string;
|
|
106
|
-
export default src;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
declare module '*.gif?url' {
|
|
110
|
-
const src: string;
|
|
111
|
-
export default src;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
declare module '*.jpg?url' {
|
|
115
|
-
const src: string;
|
|
116
|
-
export default src;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
declare module '*.jpeg?url' {
|
|
120
|
-
const src: string;
|
|
121
|
-
export default src;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
declare module '*.png?url' {
|
|
125
|
-
const src: string;
|
|
126
|
-
export default src;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
declare module '*.ico?url' {
|
|
130
|
-
const src: string;
|
|
131
|
-
export default src;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
declare module '*.webp?url' {
|
|
135
|
-
const src: string;
|
|
136
|
-
export default src;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
declare module '*.svg?url' {
|
|
140
|
-
import * as React from 'react';
|
|
141
|
-
|
|
142
|
-
export const ReactComponent: React.FunctionComponent<
|
|
143
|
-
React.SVGProps<SVGSVGElement>
|
|
144
|
-
>;
|
|
145
|
-
|
|
146
48
|
const src: string;
|
|
147
49
|
export default src;
|
|
148
50
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"module-tools",
|
|
12
12
|
"lib-tools"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.10.1-beta.
|
|
14
|
+
"version": "2.10.1-beta.1",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js",
|
|
17
17
|
"modern-module": "./bin/modern.js"
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"@modern-js/new-action": "2.10.0",
|
|
44
44
|
"@modern-js/plugin": "2.10.0",
|
|
45
45
|
"@modern-js/plugin-changeset": "2.10.0",
|
|
46
|
-
"@modern-js/upgrade": "2.10.0",
|
|
47
|
-
"@modern-js/utils": "2.10.0",
|
|
48
46
|
"@modern-js/plugin-i18n": "2.10.0",
|
|
49
|
-
"@modern-js/plugin-lint": "2.10.0"
|
|
47
|
+
"@modern-js/plugin-lint": "2.10.0",
|
|
48
|
+
"@modern-js/upgrade": "2.10.0",
|
|
49
|
+
"@modern-js/utils": "2.10.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@modern-js/self": "npm:@modern-js/module-tools@*",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"postcss-alias": "2.0.0",
|
|
62
62
|
"react": "17",
|
|
63
63
|
"typescript": "^4",
|
|
64
|
-
"@modern-js/builder-webpack-provider": "2.10.0",
|
|
65
64
|
"@scripts/build": "2.10.0",
|
|
65
|
+
"@modern-js/builder-webpack-provider": "2.10.0",
|
|
66
66
|
"@scripts/jest-config": "2.10.0"
|
|
67
67
|
},
|
|
68
68
|
"publishConfig": {
|