smartbundle 0.3.0-alpha.2 → 0.3.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.
@@ -14,6 +14,18 @@ const errors = {
14
14
  binString: "The `bin` field must be a string. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#bin",
15
15
  rollupError: "An error occurred while building the package. Please, report it to the issues on GitHub",
16
16
  typescriptNotFound: "The package.json contains typescript entrypoints, but the typescript package is not found. Please, install typescript@^5.0.0",
17
- optionalDependenciesInvalid: "The `optionalDependencies` field must be an Object<string, string>. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#optionaldependencies"
17
+ optionalDependenciesInvalid: "The `optionalDependencies` field must be an Object<string, string>. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#optionaldependencies",
18
+ repositoryInvalid: "The `repository` field must be an object with 'type' and 'url' properties or a string. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository",
19
+ keywordsInvalid: "The `keywords` field must be an array of strings. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#keywords",
20
+ authorInvalid: "The `author` field must be an object or a string. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#people-fields-author-contributors",
21
+ contributorsInvalid: "The `contributors` field must be an array of objects or strings. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#people-fields-author-contributors",
22
+ licenseInvalid: "The `license` field must be a string specifying the license. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#license",
23
+ devDependenciesInvalid: "The `devDependencies` field must be an Object<string, string>. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#devdependencies",
24
+ peerDependenciesInvalid: "The `peerDependencies` field must be an Object<string, string>. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#peerdependencies",
25
+ enginesInvalid: "The `engines` field must be an object specifying version requirements. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#engines",
26
+ browserInvalid: "The `browser` field must be a string or an object. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#browser",
27
+ fundingInvalid: "The `funding` field must be an object or a string. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#funding",
28
+ osInvalid: "The `os` field must be an array of strings. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#os",
29
+ cpuInvalid: "The `cpu` field must be an array of strings. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#cpu"
18
30
  };
19
31
  exports.errors = errors;
@@ -12,7 +12,19 @@ const errors = {
12
12
  binString: "The `bin` field must be a string. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#bin",
13
13
  rollupError: "An error occurred while building the package. Please, report it to the issues on GitHub",
14
14
  typescriptNotFound: "The package.json contains typescript entrypoints, but the typescript package is not found. Please, install typescript@^5.0.0",
15
- optionalDependenciesInvalid: "The `optionalDependencies` field must be an Object<string, string>. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#optionaldependencies"
15
+ optionalDependenciesInvalid: "The `optionalDependencies` field must be an Object<string, string>. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#optionaldependencies",
16
+ repositoryInvalid: "The `repository` field must be an object with 'type' and 'url' properties or a string. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository",
17
+ keywordsInvalid: "The `keywords` field must be an array of strings. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#keywords",
18
+ authorInvalid: "The `author` field must be an object or a string. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#people-fields-author-contributors",
19
+ contributorsInvalid: "The `contributors` field must be an array of objects or strings. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#people-fields-author-contributors",
20
+ licenseInvalid: "The `license` field must be a string specifying the license. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#license",
21
+ devDependenciesInvalid: "The `devDependencies` field must be an Object<string, string>. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#devdependencies",
22
+ peerDependenciesInvalid: "The `peerDependencies` field must be an Object<string, string>. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#peerdependencies",
23
+ enginesInvalid: "The `engines` field must be an object specifying version requirements. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#engines",
24
+ browserInvalid: "The `browser` field must be a string or an object. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#browser",
25
+ fundingInvalid: "The `funding` field must be an object or a string. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#funding",
26
+ osInvalid: "The `os` field must be an array of strings. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#os",
27
+ cpuInvalid: "The `cpu` field must be an array of strings. Please, verify the value. More info: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#cpu"
16
28
  };
17
29
  export {
18
30
  errors
@@ -47,7 +47,43 @@ function createPackageJsonSchema(sourceDir) {
47
47
  description: z.string({ message: errors.errors.descriptionString }).optional(),
48
48
  dependencies: dependencies(errors.errors.dependenciesInvalid),
49
49
  optionalDependencies: dependencies(errors.errors.optionalDependenciesInvalid),
50
- bin: z.string({ message: errors.errors.binString }).optional()
50
+ bin: z.string({ message: errors.errors.binString }).optional(),
51
+ repository: z.union([
52
+ z.string({ message: errors.errors.repositoryInvalid }),
53
+ z.object({
54
+ type: z.string(),
55
+ url: z.string()
56
+ }, { message: errors.errors.repositoryInvalid })
57
+ ]).optional(),
58
+ keywords: z.array(z.string(), { message: errors.errors.keywordsInvalid }).optional(),
59
+ author: z.union([
60
+ z.string({ message: errors.errors.authorInvalid }),
61
+ z.object({
62
+ name: z.string({ message: errors.errors.authorInvalid }).optional(),
63
+ email: z.string({ message: errors.errors.authorInvalid }).optional(),
64
+ url: z.string({ message: errors.errors.authorInvalid }).optional()
65
+ }, { message: errors.errors.authorInvalid })
66
+ ]).optional(),
67
+ contributors: z.array(
68
+ z.union([
69
+ z.string({ message: errors.errors.contributorsInvalid }),
70
+ z.object({}, { message: errors.errors.contributorsInvalid })
71
+ ])
72
+ ).optional(),
73
+ license: z.string({ message: errors.errors.licenseInvalid }).optional(),
74
+ devDependencies: dependencies(errors.errors.devDependenciesInvalid),
75
+ peerDependencies: dependencies(errors.errors.peerDependenciesInvalid),
76
+ engines: z.record(z.string(), { message: errors.errors.enginesInvalid }).optional(),
77
+ browser: z.union([
78
+ z.string({ message: errors.errors.browserInvalid }),
79
+ z.record(z.string(), { message: errors.errors.browserInvalid })
80
+ ]).optional(),
81
+ funding: z.union([
82
+ z.string({ message: errors.errors.fundingInvalid }),
83
+ z.object({}, { message: errors.errors.fundingInvalid })
84
+ ]).optional(),
85
+ os: z.array(z.string(), { message: errors.errors.osInvalid }).optional(),
86
+ cpu: z.array(z.string(), { message: errors.errors.cpuInvalid }).optional()
51
87
  });
52
88
  }
53
89
  async function parsePackageJson({
@@ -28,7 +28,43 @@ function createPackageJsonSchema(sourceDir) {
28
28
  description: z.string({ message: errors.descriptionString }).optional(),
29
29
  dependencies: dependencies(errors.dependenciesInvalid),
30
30
  optionalDependencies: dependencies(errors.optionalDependenciesInvalid),
31
- bin: z.string({ message: errors.binString }).optional()
31
+ bin: z.string({ message: errors.binString }).optional(),
32
+ repository: z.union([
33
+ z.string({ message: errors.repositoryInvalid }),
34
+ z.object({
35
+ type: z.string(),
36
+ url: z.string()
37
+ }, { message: errors.repositoryInvalid })
38
+ ]).optional(),
39
+ keywords: z.array(z.string(), { message: errors.keywordsInvalid }).optional(),
40
+ author: z.union([
41
+ z.string({ message: errors.authorInvalid }),
42
+ z.object({
43
+ name: z.string({ message: errors.authorInvalid }).optional(),
44
+ email: z.string({ message: errors.authorInvalid }).optional(),
45
+ url: z.string({ message: errors.authorInvalid }).optional()
46
+ }, { message: errors.authorInvalid })
47
+ ]).optional(),
48
+ contributors: z.array(
49
+ z.union([
50
+ z.string({ message: errors.contributorsInvalid }),
51
+ z.object({}, { message: errors.contributorsInvalid })
52
+ ])
53
+ ).optional(),
54
+ license: z.string({ message: errors.licenseInvalid }).optional(),
55
+ devDependencies: dependencies(errors.devDependenciesInvalid),
56
+ peerDependencies: dependencies(errors.peerDependenciesInvalid),
57
+ engines: z.record(z.string(), { message: errors.enginesInvalid }).optional(),
58
+ browser: z.union([
59
+ z.string({ message: errors.browserInvalid }),
60
+ z.record(z.string(), { message: errors.browserInvalid })
61
+ ]).optional(),
62
+ funding: z.union([
63
+ z.string({ message: errors.fundingInvalid }),
64
+ z.object({}, { message: errors.fundingInvalid })
65
+ ]).optional(),
66
+ os: z.array(z.string(), { message: errors.osInvalid }).optional(),
67
+ cpu: z.array(z.string(), { message: errors.cpuInvalid }).optional()
32
68
  });
33
69
  }
34
70
  async function parsePackageJson({
@@ -39,7 +39,19 @@ async function writePackageJson(outDir, parsed, { exportsMap }) {
39
39
  description: parsed.description ?? "",
40
40
  exports: allExports,
41
41
  dependencies: parsed.dependencies ?? void 0,
42
- optionalDependencies: parsed.optionalDependencies ?? void 0
42
+ optionalDependencies: parsed.optionalDependencies ?? void 0,
43
+ repository: parsed.repository,
44
+ keywords: parsed.keywords,
45
+ author: parsed.author,
46
+ contributors: parsed.contributors,
47
+ license: parsed.license,
48
+ devDependencies: parsed.devDependencies,
49
+ peerDependencies: parsed.peerDependencies,
50
+ engines: parsed.engines,
51
+ browser: parsed.browser,
52
+ funding: parsed.funding,
53
+ os: parsed.os,
54
+ cpu: parsed.cpu
43
55
  };
44
56
  await fs.writeFile(`${outDir}/package.json`, JSON.stringify(res, null, 2));
45
57
  }
@@ -37,7 +37,19 @@ async function writePackageJson(outDir, parsed, { exportsMap }) {
37
37
  description: parsed.description ?? "",
38
38
  exports: allExports,
39
39
  dependencies: parsed.dependencies ?? void 0,
40
- optionalDependencies: parsed.optionalDependencies ?? void 0
40
+ optionalDependencies: parsed.optionalDependencies ?? void 0,
41
+ repository: parsed.repository,
42
+ keywords: parsed.keywords,
43
+ author: parsed.author,
44
+ contributors: parsed.contributors,
45
+ license: parsed.license,
46
+ devDependencies: parsed.devDependencies,
47
+ peerDependencies: parsed.peerDependencies,
48
+ engines: parsed.engines,
49
+ browser: parsed.browser,
50
+ funding: parsed.funding,
51
+ os: parsed.os,
52
+ cpu: parsed.cpu
41
53
  };
42
54
  await writeFile(`${outDir}/package.json`, JSON.stringify(res, null, 2));
43
55
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "smartbundle",
3
3
  "type": "module",
4
- "version": "0.3.0-alpha.2",
4
+ "version": "0.3.0",
5
5
  "bin": "./src/bin.js",
6
6
  "types": "./src/run.d.ts",
7
7
  "module": "./src/run.js",
8
- "description": "",
8
+ "description": "zero-config bundler for npm packages",
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./src/run.d.ts",
@@ -27,5 +27,31 @@
27
27
  },
28
28
  "optionalDependencies": {
29
29
  "typescript": "^5.0.0"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/xavescor/smartbundle"
34
+ },
35
+ "keywords": [
36
+ "smartbundle",
37
+ "bundler",
38
+ "npm",
39
+ "package",
40
+ "typescript",
41
+ "esm",
42
+ "cjs"
43
+ ],
44
+ "author": {
45
+ "name": "Andrey Vassilyev",
46
+ "email": "xavescor@xavescor.dev"
47
+ },
48
+ "license": "MIT",
49
+ "devDependencies": {
50
+ "@types/node": "^20.14.11",
51
+ "@types/yargs": "^17.0.32",
52
+ "prettier": "^3.3.3",
53
+ "typescript": "^5.5.3",
54
+ "vitest": "^2.0.4",
55
+ "vitest-directory-snapshot": "^0.2.2"
30
56
  }
31
57
  }
package/src/errors.d.ts CHANGED
@@ -13,4 +13,16 @@ export declare const errors: {
13
13
  rollupError: string;
14
14
  typescriptNotFound: string;
15
15
  optionalDependenciesInvalid: string;
16
+ repositoryInvalid: string;
17
+ keywordsInvalid: string;
18
+ authorInvalid: string;
19
+ contributorsInvalid: string;
20
+ licenseInvalid: string;
21
+ devDependenciesInvalid: string;
22
+ peerDependenciesInvalid: string;
23
+ enginesInvalid: string;
24
+ browserInvalid: string;
25
+ fundingInvalid: string;
26
+ osInvalid: string;
27
+ cpuInvalid: string;
16
28
  };
@@ -8,6 +8,39 @@ declare function createPackageJsonSchema(sourceDir: string): z.ZodObject<{
8
8
  dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
9
9
  optionalDependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
10
10
  bin: z.ZodOptional<z.ZodString>;
11
+ repository: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
12
+ type: z.ZodString;
13
+ url: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ type?: string;
16
+ url?: string;
17
+ }, {
18
+ type?: string;
19
+ url?: string;
20
+ }>]>>;
21
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
22
+ author: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
23
+ name: z.ZodOptional<z.ZodString>;
24
+ email: z.ZodOptional<z.ZodString>;
25
+ url: z.ZodOptional<z.ZodString>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ name?: string;
28
+ url?: string;
29
+ email?: string;
30
+ }, {
31
+ name?: string;
32
+ url?: string;
33
+ email?: string;
34
+ }>]>>;
35
+ contributors: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>, "many">>;
36
+ license: z.ZodOptional<z.ZodString>;
37
+ devDependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
38
+ peerDependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
39
+ engines: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
40
+ browser: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
41
+ funding: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>;
42
+ os: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
43
+ cpu: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
11
44
  }, "strip", z.ZodTypeAny, {
12
45
  exports?: string;
13
46
  name?: string;
@@ -17,6 +50,25 @@ declare function createPackageJsonSchema(sourceDir: string): z.ZodObject<{
17
50
  dependencies?: Record<string, string>;
18
51
  optionalDependencies?: Record<string, string>;
19
52
  bin?: string;
53
+ repository?: string | {
54
+ type?: string;
55
+ url?: string;
56
+ };
57
+ keywords?: string[];
58
+ author?: string | {
59
+ name?: string;
60
+ url?: string;
61
+ email?: string;
62
+ };
63
+ contributors?: (string | {})[];
64
+ license?: string;
65
+ devDependencies?: Record<string, string>;
66
+ peerDependencies?: Record<string, string>;
67
+ engines?: Record<string, string>;
68
+ browser?: string | Record<string, string>;
69
+ funding?: string | {};
70
+ os?: string[];
71
+ cpu?: string[];
20
72
  }, {
21
73
  exports?: string;
22
74
  name?: string;
@@ -26,6 +78,25 @@ declare function createPackageJsonSchema(sourceDir: string): z.ZodObject<{
26
78
  dependencies?: Record<string, string>;
27
79
  optionalDependencies?: Record<string, string>;
28
80
  bin?: string;
81
+ repository?: string | {
82
+ type?: string;
83
+ url?: string;
84
+ };
85
+ keywords?: string[];
86
+ author?: string | {
87
+ name?: string;
88
+ url?: string;
89
+ email?: string;
90
+ };
91
+ contributors?: (string | {})[];
92
+ license?: string;
93
+ devDependencies?: Record<string, string>;
94
+ peerDependencies?: Record<string, string>;
95
+ engines?: Record<string, string>;
96
+ browser?: string | Record<string, string>;
97
+ funding?: string | {};
98
+ os?: string[];
99
+ cpu?: string[];
29
100
  }>;
30
101
  type PackageJsonSchema = ReturnType<typeof createPackageJsonSchema>;
31
102
  export type PackageJson = z.infer<PackageJsonSchema>;