migrate component foundation to OpenVue 1.1.1
This commit is contained in:
1 parent
651c36367f
commit
21692898b3
135 files changed
+780
-749
No files matched your search
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { createRequire } from "node:module";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { parse as parseJavaScript } from "@babel/parser";
|
||||
import {
|
||||
parse as parseVue,
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
} from "@vue/compiler-sfc";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "..");
|
||||
const require = createRequire(import.meta.url);
|
||||
const failures = [];
|
||||
const files = [];
|
||||
function walk(directory) {
|
||||
@@ -53,7 +52,13 @@ function checkImport(source, owner) {
|
||||
if (!dependencies.has(name))
|
||||
failures.push(`${owner}: undeclared dependency ${name}`);
|
||||
try {
|
||||
require.resolve(source);
|
||||
// 应用使用 ESM import;按 import 条件解析,不能用 require 条件拒绝 ESM-only 包。
|
||||
const resolved = import.meta.resolve(source);
|
||||
if (
|
||||
resolved.startsWith("file:") &&
|
||||
!fs.existsSync(fileURLToPath(resolved))
|
||||
)
|
||||
throw Error(`Resolved module does not exist: ${resolved}`);
|
||||
} catch (error) {
|
||||
failures.push(`${owner}: cannot resolve ${source}: ${error.message}`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user