smartbundle 0.5.4-alpha.0 → 0.6.0
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/__do_not_import_directly__/createViteConfig.cjs +4 -2
- package/__do_not_import_directly__/createViteConfig.js +4 -2
- package/__do_not_import_directly__/errors.cjs +1 -1
- package/__do_not_import_directly__/errors.js +1 -1
- package/__do_not_import_directly__/packageJson.cjs +24 -3
- package/__do_not_import_directly__/packageJson.js +24 -3
- package/package.json +1 -1
- package/src/packageJson.d.ts +3 -3
@@ -41,8 +41,10 @@ function createViteConfig({ dirs, packageJson }) {
|
|
41
41
|
const { sourceDir, outDir } = dirs;
|
42
42
|
const entrypoints = /* @__PURE__ */ new Map();
|
43
43
|
if (packageJson.exports) {
|
44
|
-
const
|
45
|
-
|
44
|
+
for (const [key, value] of packageJson.exports.entries()) {
|
45
|
+
const entry = path.join(sourceDir, value);
|
46
|
+
entrypoints.set(key, entry);
|
47
|
+
}
|
46
48
|
}
|
47
49
|
if (packageJson.bin) {
|
48
50
|
const binEntry = path.join(sourceDir, packageJson.bin);
|
@@ -39,8 +39,10 @@ function createViteConfig({ dirs, packageJson }) {
|
|
39
39
|
const { sourceDir, outDir } = dirs;
|
40
40
|
const entrypoints = /* @__PURE__ */ new Map();
|
41
41
|
if (packageJson.exports) {
|
42
|
-
const
|
43
|
-
|
42
|
+
for (const [key, value] of packageJson.exports.entries()) {
|
43
|
+
const entry = join(sourceDir, value);
|
44
|
+
entrypoints.set(key, entry);
|
45
|
+
}
|
44
46
|
}
|
45
47
|
if (packageJson.bin) {
|
46
48
|
const binEntry = join(sourceDir, packageJson.bin);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
3
|
const errors = {
|
4
|
-
exportsRequired: "The `exports` field is string
|
4
|
+
exportsRequired: "The `exports` field is string or Record<string, string>. Please, verify the value. More info: https://nodejs.org/api/packages.html#package-entry-points",
|
5
5
|
exportsInvalid: "The `exports` field must be a path to entrypoint. Please, verify the value. More info: https://nodejs.org/api/packages.html#package-entry-points",
|
6
6
|
nameRequired: "The `name` field is required string. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#name",
|
7
7
|
nameMinLength: 'Min length of "name" is 1 character. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#name',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
const errors = {
|
2
|
-
exportsRequired: "The `exports` field is string
|
2
|
+
exportsRequired: "The `exports` field is string or Record<string, string>. Please, verify the value. More info: https://nodejs.org/api/packages.html#package-entry-points",
|
3
3
|
exportsInvalid: "The `exports` field must be a path to entrypoint. Please, verify the value. More info: https://nodejs.org/api/packages.html#package-entry-points",
|
4
4
|
nameRequired: "The `name` field is required string. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#name",
|
5
5
|
nameMinLength: 'Min length of "name" is 1 character. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#name',
|
@@ -32,11 +32,32 @@ async function fileExists(filePath) {
|
|
32
32
|
function dependencies(errorText) {
|
33
33
|
return z.record(z.string({ message: errorText }), { message: errorText }).optional();
|
34
34
|
}
|
35
|
+
function createPathValidator(sourceDir) {
|
36
|
+
return (path$1) => {
|
37
|
+
const finalPath = path.join(sourceDir, path$1);
|
38
|
+
return fileExists(finalPath);
|
39
|
+
};
|
40
|
+
}
|
35
41
|
function createPackageJsonSchema(sourceDir) {
|
42
|
+
const pathValidator = createPathValidator(sourceDir);
|
36
43
|
return z.object({
|
37
|
-
exports: z.
|
38
|
-
|
39
|
-
|
44
|
+
exports: z.union(
|
45
|
+
[
|
46
|
+
z.string().transform((path2) => /* @__PURE__ */ new Map([[".", path2]])),
|
47
|
+
z.record(z.string()).transform((obj) => new Map(Object.entries(obj)))
|
48
|
+
],
|
49
|
+
{
|
50
|
+
errorMap() {
|
51
|
+
return { message: errors.errors.exportsRequired };
|
52
|
+
}
|
53
|
+
}
|
54
|
+
).refine(async (obj) => {
|
55
|
+
for (const [key, value] of obj.entries()) {
|
56
|
+
if (!await pathValidator(value)) {
|
57
|
+
return false;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
return true;
|
40
61
|
}, errors.errors.exportsInvalid).optional(),
|
41
62
|
name: z.string({ message: errors.errors.nameRequired }).min(1, errors.errors.nameMinLength).max(214, errors.errors.nameMaxLength).refine(
|
42
63
|
(name) => ["_", "."].every((start) => !name.startsWith(start)),
|
@@ -13,11 +13,32 @@ async function fileExists(filePath) {
|
|
13
13
|
function dependencies(errorText) {
|
14
14
|
return z.record(z.string({ message: errorText }), { message: errorText }).optional();
|
15
15
|
}
|
16
|
+
function createPathValidator(sourceDir) {
|
17
|
+
return (path) => {
|
18
|
+
const finalPath = join(sourceDir, path);
|
19
|
+
return fileExists(finalPath);
|
20
|
+
};
|
21
|
+
}
|
16
22
|
function createPackageJsonSchema(sourceDir) {
|
23
|
+
const pathValidator = createPathValidator(sourceDir);
|
17
24
|
return z.object({
|
18
|
-
exports: z.
|
19
|
-
|
20
|
-
|
25
|
+
exports: z.union(
|
26
|
+
[
|
27
|
+
z.string().transform((path) => /* @__PURE__ */ new Map([[".", path]])),
|
28
|
+
z.record(z.string()).transform((obj) => new Map(Object.entries(obj)))
|
29
|
+
],
|
30
|
+
{
|
31
|
+
errorMap() {
|
32
|
+
return { message: errors.exportsRequired };
|
33
|
+
}
|
34
|
+
}
|
35
|
+
).refine(async (obj) => {
|
36
|
+
for (const [key, value] of obj.entries()) {
|
37
|
+
if (!await pathValidator(value)) {
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
return true;
|
21
42
|
}, errors.exportsInvalid).optional(),
|
22
43
|
name: z.string({ message: errors.nameRequired }).min(1, errors.nameMinLength).max(214, errors.nameMaxLength).refine(
|
23
44
|
(name) => ["_", "."].every((start) => !name.startsWith(start)),
|
package/package.json
CHANGED
package/src/packageJson.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import z from "zod";
|
2
2
|
declare function createPackageJsonSchema(sourceDir: string): z.ZodObject<{
|
3
|
-
exports: z.ZodOptional<z.ZodEffects<z.ZodString, string, string
|
3
|
+
exports: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, Map<string, string>, string>, z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodString>, Map<string, string>, Record<string, string>>]>, Map<string, string>, string | Record<string, string>>>;
|
4
4
|
name: z.ZodEffects<z.ZodString, string, string>;
|
5
5
|
version: z.ZodString;
|
6
6
|
private: z.ZodEffects<z.ZodBoolean, boolean, boolean>;
|
@@ -26,7 +26,7 @@ declare function createPackageJsonSchema(sourceDir: string): z.ZodObject<{
|
|
26
26
|
unpkg: z.ZodOptional<z.ZodAny>;
|
27
27
|
homepage: z.ZodOptional<z.ZodAny>;
|
28
28
|
}, "strip", z.ZodTypeAny, {
|
29
|
-
exports?: string
|
29
|
+
exports?: Map<string, string>;
|
30
30
|
name?: string;
|
31
31
|
version?: string;
|
32
32
|
private?: boolean;
|
@@ -52,7 +52,7 @@ declare function createPackageJsonSchema(sourceDir: string): z.ZodObject<{
|
|
52
52
|
unpkg?: any;
|
53
53
|
homepage?: any;
|
54
54
|
}, {
|
55
|
-
exports?: string
|
55
|
+
exports?: string | Record<string, string>;
|
56
56
|
name?: string;
|
57
57
|
version?: string;
|
58
58
|
private?: boolean;
|