esmate 0.0.1 → 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.
@@ -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.string().refine((value) => fs.existsSync(value), (value) => ({
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.string().refine((key) => this.exports[key].replace('src/', '').startsWith(key), {
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
- }), z
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,
@@ -75,7 +88,7 @@ class ESMate {
75
88
  for (const key in this.package.bin) {
76
89
  const value = this.package.bin[key];
77
90
  const { dir, name } = path.parse(value);
78
- newBin[key] = `${dir}/${name}.js`;
91
+ newBin[key] = `${dir.replace('/src/', '/')}/${name}.js`;
79
92
  }
80
93
  return newBin;
81
94
  })(), exports: (() => {
@@ -83,7 +96,7 @@ class ESMate {
83
96
  for (const key in this.package.exports) {
84
97
  const value = this.package.exports[key];
85
98
  const { dir, name } = path.parse(value);
86
- const out = `${dir}/${name}`;
99
+ const out = `${dir.replace('/src/', '/')}/${name}`;
87
100
  newExports[key] = {
88
101
  import: out + '.js',
89
102
  types: out + '.d.ts',
@@ -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, path.join('dist', 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.1",
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",
@@ -32,20 +31,20 @@
32
31
  "zod": "^3.24.2"
33
32
  },
34
33
  "bin": {
35
- "esm": "src/cli/index.js"
34
+ "esm": "./cli/index.js"
36
35
  },
37
36
  "exports": {
38
37
  "./eslint": {
39
- "import": "./src/eslint/index.js",
40
- "types": "./src/eslint/index.d.ts"
38
+ "import": "./eslint/index.js",
39
+ "types": "./eslint/index.d.ts"
41
40
  },
42
41
  "./prettier": {
43
- "import": "./src/prettier/index.js",
44
- "types": "./src/prettier/index.d.ts"
42
+ "import": "./prettier/index.js",
43
+ "types": "./prettier/index.d.ts"
45
44
  },
46
45
  "./vite": {
47
- "import": "./src/vite/index.js",
48
- "types": "./src/vite/index.d.ts"
46
+ "import": "./vite/index.js",
47
+ "types": "./vite/index.d.ts"
49
48
  }
50
49
  }
51
50
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes