pkg-scaffold 3.3.3 → 3.3.4
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/README.md +63 -22
- package/bin/cli.js +5 -5
- package/package.json +2 -2
- package/pnpm-workspace.yaml +2 -0
- package/src/EngineContext.js +14 -0
- package/src/ast/ASTAnalyzer.js +243 -116
- package/src/ast/BarrelParser.js +29 -17
- package/src/ast/DeadCodeDetector.js +73 -0
- package/src/ast/MagicDetector.js +3 -1
- package/src/ast/OxcAnalyzer.js +193 -81
- package/src/index.js +10 -11
- package/src/plugins/PluginRegistry.js +1 -0
- package/src/plugins/ecosystems/MorePlugins.js +184 -0
- package/src/plugins/ecosystems/PluginLoader.js +20 -0
- package/src/resolution/CircularDetector.js +3 -34
- package/src/resolution/ConfigLoader.js +34 -6
- package/src/resolution/WorkSpaceGraph.js +15 -1
|
@@ -13,40 +13,68 @@ export class ConfigLoader {
|
|
|
13
13
|
|
|
14
14
|
async loadConfig(projectRoot) {
|
|
15
15
|
const searchPaths = [
|
|
16
|
+
'pkg-scaffold.json',
|
|
17
|
+
'pkg-scaffold.jsonc',
|
|
18
|
+
'.pkg-scaffold.json',
|
|
19
|
+
'.pkg-scaffold.jsonc',
|
|
20
|
+
'pkg-scaffold.js',
|
|
21
|
+
'pkg-scaffold.ts',
|
|
22
|
+
'pkg-scaffold/config.json',
|
|
16
23
|
'scaffold.config.js',
|
|
17
24
|
'scaffold.config.mjs',
|
|
18
25
|
'.scaffoldrc.json',
|
|
19
26
|
'.scaffoldrc'
|
|
20
27
|
];
|
|
21
28
|
|
|
29
|
+
let config = this.getDefaultConfig();
|
|
30
|
+
|
|
31
|
+
// Try package.json first
|
|
32
|
+
try {
|
|
33
|
+
const pkgPath = path.join(projectRoot, 'package.json');
|
|
34
|
+
const pkgContent = await fs.readFile(pkgPath, 'utf8');
|
|
35
|
+
const pkg = JSON.parse(pkgContent);
|
|
36
|
+
if (pkg['pkg-scaffold']) {
|
|
37
|
+
Object.assign(config, pkg['pkg-scaffold']);
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
// ignore
|
|
41
|
+
}
|
|
42
|
+
|
|
22
43
|
for (const fileName of searchPaths) {
|
|
23
44
|
const fullPath = path.join(projectRoot, fileName);
|
|
24
45
|
try {
|
|
25
46
|
await fs.access(fullPath);
|
|
26
47
|
|
|
27
|
-
if (fileName.endsWith('.js') || fileName.endsWith('.mjs')) {
|
|
48
|
+
if (fileName.endsWith('.js') || fileName.endsWith('.mjs') || fileName.endsWith('.ts')) {
|
|
28
49
|
const module = await import(pathToFileURL(fullPath).href);
|
|
29
|
-
|
|
50
|
+
Object.assign(config, module.default || module);
|
|
51
|
+
break;
|
|
30
52
|
} else {
|
|
31
53
|
const content = await fs.readFile(fullPath, 'utf8');
|
|
32
|
-
|
|
54
|
+
// Very basic JSONC parsing (strip comments)
|
|
55
|
+
const stripped = content.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '');
|
|
56
|
+
Object.assign(config, JSON.parse(stripped));
|
|
57
|
+
break;
|
|
33
58
|
}
|
|
34
59
|
} catch (e) {
|
|
35
60
|
continue;
|
|
36
61
|
}
|
|
37
62
|
}
|
|
38
63
|
|
|
39
|
-
return
|
|
64
|
+
return config;
|
|
40
65
|
}
|
|
41
66
|
|
|
42
67
|
getDefaultConfig() {
|
|
43
68
|
return {
|
|
44
|
-
entryPoints: ['src/index.ts', 'index.js'],
|
|
69
|
+
entryPoints: ['src/index.ts', 'index.js', 'src/index.js', 'src/main.ts', 'src/main.js'],
|
|
45
70
|
exclude: [
|
|
46
71
|
'node_modules/**',
|
|
47
72
|
'dist/**',
|
|
73
|
+
'build/**',
|
|
48
74
|
'**/*.test.ts',
|
|
49
|
-
'**/*.spec.ts'
|
|
75
|
+
'**/*.spec.ts',
|
|
76
|
+
'**/*.test.js',
|
|
77
|
+
'**/*.spec.js'
|
|
50
78
|
],
|
|
51
79
|
plugins: [],
|
|
52
80
|
rules: {
|
|
@@ -62,10 +62,16 @@ export class WorkspaceGraph {
|
|
|
62
62
|
workspaceGlobs = Array.isArray(pkg.workspaces) ? pkg.workspaces : (pkg.workspaces.packages || []);
|
|
63
63
|
}
|
|
64
64
|
} catch {
|
|
65
|
-
|
|
65
|
+
// No workspaces found
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
if (workspaceGlobs.length > 0) {
|
|
70
|
+
this.context.isWorkspaceEnabled = true;
|
|
71
|
+
} else {
|
|
72
|
+
return; // Workspace mesh maps skipped for single-package targets
|
|
73
|
+
}
|
|
74
|
+
|
|
69
75
|
// Crawl target glob configurations to locate workspace packages
|
|
70
76
|
for (const pattern of workspaceGlobs) {
|
|
71
77
|
await this.locatePackagesViaPattern(pattern);
|
|
@@ -131,8 +137,16 @@ export class WorkspaceGraph {
|
|
|
131
137
|
|
|
132
138
|
// Default file index fallback configurations
|
|
133
139
|
if (entries.size === 0) {
|
|
140
|
+
// Standard roots
|
|
134
141
|
entries.add(path.resolve(pkgDir, 'index.js'));
|
|
135
142
|
entries.add(path.resolve(pkgDir, 'index.ts'));
|
|
143
|
+
entries.add(path.resolve(pkgDir, 'index.tsx'));
|
|
144
|
+
entries.add(path.resolve(pkgDir, 'index.jsx'));
|
|
145
|
+
// Common src patterns
|
|
146
|
+
entries.add(path.resolve(pkgDir, 'src/index.ts'));
|
|
147
|
+
entries.add(path.resolve(pkgDir, 'src/index.tsx'));
|
|
148
|
+
entries.add(path.resolve(pkgDir, 'src/index.js'));
|
|
149
|
+
entries.add(path.resolve(pkgDir, 'src/index.jsx'));
|
|
136
150
|
}
|
|
137
151
|
|
|
138
152
|
return Array.from(entries);
|