mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix: 修复 windows 兼容问题
This commit is contained in:
parent
5eeb100533
commit
cc16721fd5
@ -26,8 +26,28 @@ export default class BabelRegister {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
ignore: [/node_modules/],
|
plugins: [
|
||||||
only,
|
function () {
|
||||||
|
return {
|
||||||
|
visitor: {
|
||||||
|
ExportAllDeclaration(path) {
|
||||||
|
if (path.node.source.value.startsWith('@@')) {
|
||||||
|
path.remove();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
],
|
||||||
|
only: [
|
||||||
|
...only,
|
||||||
|
function (filepath) {
|
||||||
|
if (/@fesjs[/\\]+fes/.test(filepath)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
],
|
||||||
extensions: ['.jsx', '.js', '.ts', '.tsx'],
|
extensions: ['.jsx', '.js', '.ts', '.tsx'],
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
cache: false,
|
cache: false,
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
import { dirname } from 'path';
|
||||||
import crequire from 'crequire';
|
import crequire from 'crequire';
|
||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
import resolve from 'resolve';
|
import resolve from 'resolve';
|
||||||
import { readFileSync } from 'fs';
|
|
||||||
import { dirname } from 'path';
|
|
||||||
import winPath from './winPath';
|
import winPath from './winPath';
|
||||||
|
|
||||||
function parse(filePath) {
|
function parse(filePath) {
|
||||||
const content = readFileSync(filePath, 'utf-8');
|
const content = readFileSync(filePath, 'utf-8');
|
||||||
return (crequire(content))
|
return crequire(content)
|
||||||
.map(o => o.path)
|
.map((o) => o.path)
|
||||||
.filter(path => path.charAt(0) === '.')
|
.filter((path) => path.charAt(0) === '.')
|
||||||
.map(path => winPath(
|
.map((path) =>
|
||||||
resolve.sync(path, {
|
winPath(
|
||||||
basedir: dirname(filePath),
|
resolve.sync(path, {
|
||||||
extensions: ['.tsx', '.ts', '.jsx', '.js']
|
basedir: dirname(filePath),
|
||||||
})
|
extensions: ['.tsx', '.ts', '.jsx', '.js'],
|
||||||
));
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function parseRequireDeps(filePath) {
|
export default function parseRequireDeps(filePath) {
|
||||||
@ -25,7 +26,7 @@ export default function parseRequireDeps(filePath) {
|
|||||||
const ret = [winPath(filePath)];
|
const ret = [winPath(filePath)];
|
||||||
|
|
||||||
while (paths.length) {
|
while (paths.length) {
|
||||||
// 避免依赖循环
|
// 避免依赖循环
|
||||||
const extraPaths = lodash.pullAll(parse(paths.shift()), ret);
|
const extraPaths = lodash.pullAll(parse(paths.shift()), ret);
|
||||||
if (extraPaths.length) {
|
if (extraPaths.length) {
|
||||||
paths.push(...extraPaths);
|
paths.push(...extraPaths);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user