@markuplint/file-resolver 4.9.13 → 4.9.14-dev.110

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.
Files changed (2) hide show
  1. package/lib/general-import.js +18 -23
  2. package/package.json +11 -11
@@ -19,30 +19,25 @@ export async function generalImport(name) {
19
19
  cache.set(name, mod);
20
20
  return mod;
21
21
  }
22
- catch (error) {
23
- if (
24
- // @ts-ignore
25
- 'code' in error &&
26
- // @ts-ignore
27
- error.code === 'ERR_IMPORT_ASSERTION_TYPE_MISSING') {
28
- try {
29
- const mod = require(name) ?? null;
30
- gLogSuccess('Success by require("%s"): %O', name, mod);
31
- cache.set(name, mod);
32
- return mod;
33
- }
34
- catch (error) {
35
- if (error instanceof Error && /^parse failure/i.test(error.message)) {
36
- gLogError('Error in `createRequire(import.meta.url)()`: %O', error);
37
- cache.set(name, null);
38
- return null;
39
- }
40
- gLogError('Error in generalImport: %O', error);
22
+ catch (importError) {
23
+ gLog('Error in `import()`: %O', importError);
24
+ // If import() fails, try require() regardless of error code
25
+ try {
26
+ const mod = require(name) ?? null;
27
+ gLogSuccess('Success by require("%s"): %O', name, mod);
28
+ cache.set(name, mod);
29
+ return mod;
30
+ }
31
+ catch (requireError) {
32
+ if (requireError instanceof Error && /^parse failure/i.test(requireError.message)) {
33
+ gLogError('Error in `createRequire(import.meta.url)()`: %O', requireError);
34
+ cache.set(name, null);
35
+ return null;
41
36
  }
37
+ gLogError('Error in generalImport: %O', requireError);
42
38
  }
43
- if (error instanceof Error) {
44
- const { filePath, packageName } = /Missing\s"(?<filePath>[^"]+)"\sspecifier\sin\s"(?<packageName>[^"]+)"\spackage/.exec(error.message)
45
- ?.groups ?? {};
39
+ if (importError instanceof Error) {
40
+ const { filePath, packageName } = /Missing\s"(?<filePath>[^"]+)"\sspecifier\sin\s"(?<packageName>[^"]+)"\spackage/.exec(importError.message)?.groups ?? {};
46
41
  if (filePath && packageName) {
47
42
  const modFile = resolve(packageName, import.meta.url);
48
43
  const modPath = path.dirname(modFile);
@@ -60,7 +55,7 @@ export async function generalImport(name) {
60
55
  cache.set(name, json);
61
56
  return json;
62
57
  }
63
- gLogError('Error in `import()`: %O', error);
58
+ gLogError('Error in `import()`: %O', importError);
64
59
  cache.set(name, null);
65
60
  return null;
66
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/file-resolver",
3
- "version": "4.9.13",
3
+ "version": "4.9.14-dev.110+16e148e6e",
4
4
  "description": "The file resolver of markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -25,17 +25,17 @@
25
25
  "clean": "tsc --build --clean"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/node": "22.13.10"
28
+ "@types/node": "22.14.1"
29
29
  },
30
30
  "dependencies": {
31
- "@markuplint/html-parser": "4.6.18",
32
- "@markuplint/ml-ast": "4.4.9",
33
- "@markuplint/ml-config": "4.8.10",
34
- "@markuplint/ml-core": "4.12.3",
35
- "@markuplint/ml-spec": "4.9.5",
36
- "@markuplint/parser-utils": "4.8.6",
37
- "@markuplint/selector": "4.7.3",
38
- "@markuplint/shared": "4.4.10",
31
+ "@markuplint/html-parser": "4.6.19-dev.110+16e148e6e",
32
+ "@markuplint/ml-ast": "4.4.10-dev.350+16e148e6e",
33
+ "@markuplint/ml-config": "4.8.11-dev.110+16e148e6e",
34
+ "@markuplint/ml-core": "4.12.4-dev.110+16e148e6e",
35
+ "@markuplint/ml-spec": "4.9.6-dev.110+16e148e6e",
36
+ "@markuplint/parser-utils": "4.8.7-dev.110+16e148e6e",
37
+ "@markuplint/selector": "4.7.4-dev.110+16e148e6e",
38
+ "@markuplint/shared": "4.4.11-dev.350+16e148e6e",
39
39
  "cosmiconfig": "9.0.0",
40
40
  "debug": "4.4.0",
41
41
  "glob": "11.0.1",
@@ -44,5 +44,5 @@
44
44
  "jsonc": "2.0.0",
45
45
  "minimatch": "10.0.1"
46
46
  },
47
- "gitHead": "04924b5471e60820d28c1f48c2f09a537a1e9825"
47
+ "gitHead": "16e148e6ec2abac673c5ea1e42bbb666d421f357"
48
48
  }