@modern-js/babel-compiler 2.69.5 → 3.0.0-alpha.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/dist/cjs/build.js +68 -73
- package/dist/cjs/buildWatch.js +111 -116
- package/dist/cjs/compiler.js +103 -116
- package/dist/cjs/compilerErrorResult.js +61 -56
- package/dist/cjs/constants.js +36 -28
- package/dist/cjs/defaults.js +46 -38
- package/dist/cjs/getFinalOption.js +82 -83
- package/dist/cjs/index.js +92 -44
- package/dist/cjs/type.js +17 -15
- package/dist/cjs/utils.js +34 -37
- package/dist/cjs/validate.js +70 -64
- package/dist/esm/build.mjs +42 -0
- package/dist/esm/buildWatch.mjs +78 -0
- package/dist/esm/compiler.mjs +76 -0
- package/dist/esm/compilerErrorResult.mjs +34 -0
- package/dist/esm/constants.mjs +7 -0
- package/dist/esm/defaults.mjs +17 -0
- package/dist/esm/getFinalOption.mjs +50 -0
- package/dist/{esm-node/index.js → esm/index.mjs} +7 -14
- package/dist/esm/utils.mjs +5 -0
- package/dist/esm/validate.mjs +32 -0
- package/dist/esm-node/build.mjs +42 -0
- package/dist/esm-node/buildWatch.mjs +78 -0
- package/dist/esm-node/compiler.mjs +76 -0
- package/dist/esm-node/compilerErrorResult.mjs +34 -0
- package/dist/esm-node/constants.mjs +7 -0
- package/dist/esm-node/defaults.mjs +17 -0
- package/dist/esm-node/getFinalOption.mjs +50 -0
- package/dist/esm-node/index.mjs +14 -0
- package/dist/esm-node/utils.mjs +5 -0
- package/dist/esm-node/validate.mjs +32 -0
- package/package.json +24 -17
- package/rslib.config.mts +4 -0
- package/rstest.config.ts +7 -0
- package/dist/esm/build.js +0 -105
- package/dist/esm/buildWatch.js +0 -157
- package/dist/esm/compiler.js +0 -95
- package/dist/esm/compilerErrorResult.js +0 -71
- package/dist/esm/constants.js +0 -9
- package/dist/esm/defaults.js +0 -19
- package/dist/esm/getFinalOption.js +0 -68
- package/dist/esm/index.js +0 -46
- package/dist/esm/utils.js +0 -7
- package/dist/esm/validate.js +0 -44
- package/dist/esm-node/build.js +0 -57
- package/dist/esm-node/buildWatch.js +0 -89
- package/dist/esm-node/compiler.js +0 -95
- package/dist/esm-node/compilerErrorResult.js +0 -39
- package/dist/esm-node/constants.js +0 -9
- package/dist/esm-node/defaults.js +0 -19
- package/dist/esm-node/getFinalOption.js +0 -67
- package/dist/esm-node/utils.js +0 -8
- package/dist/esm-node/validate.js +0 -44
- /package/dist/esm/{type.js → type.mjs} +0 -0
- /package/dist/esm-node/{type.js → type.mjs} +0 -0
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_EXTENSIONS } from "@babel/core";
|
|
2
|
-
import { glob } from "@modern-js/utils";
|
|
3
|
-
import { mergeDefaultOption } from "./defaults";
|
|
4
|
-
const getGlobPattern = (dir, extensions) => {
|
|
5
|
-
if (extensions.length > 1) {
|
|
6
|
-
return `${dir}/**/*{${extensions.join(",")}}`;
|
|
7
|
-
} else if (extensions.length === 1) {
|
|
8
|
-
return `${dir}/**/*${extensions[0]}`;
|
|
9
|
-
} else {
|
|
10
|
-
return `${dir}/**/*`;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const getFinalExtensions = (extensions) => {
|
|
14
|
-
const isExtensions = (ext) => Array.isArray(ext);
|
|
15
|
-
const isExtensionsFunc = (ext) => typeof ext === "function";
|
|
16
|
-
if (isExtensions(extensions)) {
|
|
17
|
-
return [
|
|
18
|
-
...extensions,
|
|
19
|
-
...DEFAULT_EXTENSIONS
|
|
20
|
-
];
|
|
21
|
-
} else if (isExtensionsFunc(extensions)) {
|
|
22
|
-
return extensions(DEFAULT_EXTENSIONS);
|
|
23
|
-
} else {
|
|
24
|
-
return DEFAULT_EXTENSIONS;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const getFilesFromDir = ({ dir, finalExt = [], ignore = [] }) => {
|
|
28
|
-
let globFindFilenames = [];
|
|
29
|
-
const globPattern = getGlobPattern(dir, finalExt);
|
|
30
|
-
globFindFilenames = glob.sync(globPattern, {
|
|
31
|
-
ignore
|
|
32
|
-
});
|
|
33
|
-
return globFindFilenames;
|
|
34
|
-
};
|
|
35
|
-
const getFinalCompilerOption = (option) => {
|
|
36
|
-
const optionWithDefault = mergeDefaultOption(option);
|
|
37
|
-
const { sourceDir, ignore, enableWatch = false, watchDir, extensions = DEFAULT_EXTENSIONS } = option;
|
|
38
|
-
let globFindFilenames = [];
|
|
39
|
-
const finalExt = getFinalExtensions(extensions);
|
|
40
|
-
if (sourceDir) {
|
|
41
|
-
globFindFilenames = getFilesFromDir({
|
|
42
|
-
dir: sourceDir,
|
|
43
|
-
ignore,
|
|
44
|
-
finalExt
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
if (enableWatch) {
|
|
48
|
-
globFindFilenames = getFilesFromDir({
|
|
49
|
-
dir: watchDir,
|
|
50
|
-
ignore,
|
|
51
|
-
finalExt
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
...optionWithDefault,
|
|
56
|
-
filenames: [
|
|
57
|
-
...optionWithDefault.filenames,
|
|
58
|
-
...globFindFilenames
|
|
59
|
-
]
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
export {
|
|
63
|
-
getFilesFromDir,
|
|
64
|
-
getFinalCompilerOption,
|
|
65
|
-
getFinalExtensions,
|
|
66
|
-
getGlobPattern
|
|
67
|
-
};
|
package/dist/esm-node/utils.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { logger } from "@modern-js/utils";
|
|
2
|
-
const sourceDirAndFileNamesValidMessage = "At least one of the sourceDir and filenames configurations must be configured";
|
|
3
|
-
const watchDirValidMessage = "should set watchDir when enableWatch is true";
|
|
4
|
-
const validateSourceDirAndFileNames = (compilerOptions) => {
|
|
5
|
-
const { sourceDir, filenames, quiet } = compilerOptions;
|
|
6
|
-
if (!sourceDir && !filenames) {
|
|
7
|
-
if (!quiet) {
|
|
8
|
-
logger.error(sourceDirAndFileNamesValidMessage);
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
code: 1,
|
|
12
|
-
message: sourceDirAndFileNamesValidMessage,
|
|
13
|
-
virtualDists: []
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
return null;
|
|
17
|
-
};
|
|
18
|
-
const validateWatchDir = (compilerOptions) => {
|
|
19
|
-
const { watchDir, enableWatch, quiet } = compilerOptions;
|
|
20
|
-
if (enableWatch && !watchDir) {
|
|
21
|
-
if (!quiet) {
|
|
22
|
-
logger.error(watchDirValidMessage);
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
code: 1,
|
|
26
|
-
message: watchDirValidMessage,
|
|
27
|
-
virtualDists: []
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
};
|
|
32
|
-
const validate = (compilerOptions) => {
|
|
33
|
-
if (compilerOptions.enableWatch) {
|
|
34
|
-
return validateWatchDir(compilerOptions);
|
|
35
|
-
}
|
|
36
|
-
return validateSourceDirAndFileNames(compilerOptions);
|
|
37
|
-
};
|
|
38
|
-
export {
|
|
39
|
-
sourceDirAndFileNamesValidMessage,
|
|
40
|
-
validate,
|
|
41
|
-
validateSourceDirAndFileNames,
|
|
42
|
-
validateWatchDir,
|
|
43
|
-
watchDirValidMessage
|
|
44
|
-
};
|
|
File without changes
|
|
File without changes
|