esmate 0.0.2 → 0.0.3
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/cli/esmate.js +18 -5
- package/package.json +1 -2
package/cli/esmate.js
CHANGED
|
@@ -19,17 +19,30 @@ class ESMate {
|
|
|
19
19
|
module: z.undefined({ message: 'The "module" field is not needed for ESM projects.' }),
|
|
20
20
|
scripts: z.record(z.string(), z.string()).optional(),
|
|
21
21
|
bin: z
|
|
22
|
-
.record(z.string(), z
|
|
22
|
+
.record(z.string(), z
|
|
23
|
+
.string()
|
|
24
|
+
.refine((value) => fs.existsSync(value), (value) => ({
|
|
23
25
|
message: 'No file matches this bin value: ' + value,
|
|
26
|
+
}))
|
|
27
|
+
.refine((value) => value.startsWith('./src/'), () => ({
|
|
28
|
+
message: 'A bin value must start with ./src/',
|
|
24
29
|
})))
|
|
25
30
|
.optional(),
|
|
26
31
|
exports: z
|
|
27
|
-
.record(z
|
|
32
|
+
.record(z
|
|
33
|
+
.string()
|
|
34
|
+
.refine((key) => this.exports[key].replace('src/', '').startsWith(key), {
|
|
28
35
|
message: 'An export value must be prefixed by its own key.',
|
|
29
|
-
})
|
|
36
|
+
})
|
|
37
|
+
.refine((key) => key.startsWith('./'), () => ({
|
|
38
|
+
message: 'An export key must start with ./',
|
|
39
|
+
})), z
|
|
30
40
|
.string()
|
|
31
41
|
.refine((value) => !value.includes('**'), (value) => ({
|
|
32
42
|
message: 'Avoid cross-directory matching in this export value: ' + value,
|
|
43
|
+
}))
|
|
44
|
+
.refine((value) => value.startsWith('./src/'), () => ({
|
|
45
|
+
message: 'An export value must start with ./src/',
|
|
33
46
|
}))
|
|
34
47
|
.refine((value) => globbySync(value).length > 0, (value) => ({
|
|
35
48
|
message: 'No file matches this export value: ' + value,
|
|
@@ -96,8 +109,8 @@ class ESMate {
|
|
|
96
109
|
fs.writeJsonSync(newPath, newPackage, { spaces: 2 });
|
|
97
110
|
}
|
|
98
111
|
includeFiles() {
|
|
99
|
-
for (const filePath of globbySync(this.package.files || [])) {
|
|
100
|
-
fs.copy(filePath,
|
|
112
|
+
for (const filePath of globbySync(this.package.files || [], { gitignore: true })) {
|
|
113
|
+
fs.copy(filePath, filePath.replace('src/', 'dist/'));
|
|
101
114
|
}
|
|
102
115
|
}
|
|
103
116
|
build() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esmate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"esmate": "lib",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"find-up": "^7.0.0",
|
|
20
20
|
"fs-extra": "^11.3.0",
|
|
21
21
|
"globby": "^14.1.0",
|
|
22
|
-
"jiti": "^2.4.2",
|
|
23
22
|
"npm-check-updates": "^17.1.18",
|
|
24
23
|
"prettier": "^3.5.3",
|
|
25
24
|
"prettier-plugin-organize-imports": "^4.1.0",
|