@idomatic/core 1.0.3 → 1.0.6
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/lib/core.js +9 -4
- package/package.json +3 -2
package/lib/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { createRequire } from "module";
|
|
3
2
|
import { pathToFileURL } from "url";
|
|
3
|
+
import resolveFrom from "resolve-from";
|
|
4
4
|
|
|
5
5
|
const parserMap = {
|
|
6
6
|
".js": "@idomatic/parser-js",
|
|
@@ -12,8 +12,6 @@ const parserMap = {
|
|
|
12
12
|
".ng.html": "@idomatic/parser-html",
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const requireFromProject = createRequire(process.cwd());
|
|
16
|
-
|
|
17
15
|
export async function processFile(filePath, config) {
|
|
18
16
|
const ext = path.extname(filePath).toLowerCase();
|
|
19
17
|
const parserPackage = parserMap[ext];
|
|
@@ -24,8 +22,15 @@ export async function processFile(filePath, config) {
|
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
try {
|
|
27
|
-
|
|
25
|
+
// Resolve the package's path from the current working directory
|
|
26
|
+
const resolvedPath = resolveFrom(process.cwd(), parserPackage);
|
|
27
|
+
console.log(`Resolved ${parserPackage} to: ${resolvedPath}`);
|
|
28
|
+
|
|
29
|
+
// Convert to a file URL for dynamic import
|
|
28
30
|
const resolvedURL = pathToFileURL(resolvedPath).href;
|
|
31
|
+
console.log(`Resolved URL: ${resolvedURL}`);
|
|
32
|
+
|
|
33
|
+
// Dynamically import the parser module
|
|
29
34
|
const parser = await import(resolvedURL);
|
|
30
35
|
await parser.default(filePath, config);
|
|
31
36
|
console.log(`✅ Updated: ${filePath}`);
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idomatic/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"idomatic": "./bin/index.js"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"globby": "^14.1.0"
|
|
9
|
+
"globby": "^14.1.0",
|
|
10
|
+
"resolve-from": "^5.0.0"
|
|
10
11
|
},
|
|
11
12
|
"keywords": [
|
|
12
13
|
"idomatic",
|