smartbundle 0.7.1 → 0.7.2
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__/resolveDirs.cjs +2 -2
- package/__do_not_import_directly__/resolveDirs.js +2 -2
- package/__do_not_import_directly__/tasks/binsTask.cjs +7 -3
- package/__do_not_import_directly__/tasks/binsTask.js +8 -4
- package/package.json +2 -2
- package/src/index.cjs +3 -5
- package/src/index.js +3 -5
- package/src/resolveDirs.d.ts +1 -1
- package/src/tasks/binsTask.d.ts +2 -2
- /package/{__smartbundle__internals__ → __bin__}/smartbundle +0 -0
@@ -14,7 +14,7 @@ function resolveDirs(args) {
|
|
14
14
|
args.packagePath ?? "./package.json"
|
15
15
|
);
|
16
16
|
const outDir = myResolve(process.cwd(), args.outputDir ?? "./dist");
|
17
|
-
const
|
18
|
-
return { sourceDir, packagePath, outDir,
|
17
|
+
const outBinsDir = myResolve(outDir, "__bin__");
|
18
|
+
return { sourceDir, packagePath, outDir, outBinsDir };
|
19
19
|
}
|
20
20
|
exports.resolveDirs = resolveDirs;
|
@@ -12,8 +12,8 @@ function resolveDirs(args) {
|
|
12
12
|
args.packagePath ?? "./package.json"
|
13
13
|
);
|
14
14
|
const outDir = myResolve(process.cwd(), args.outputDir ?? "./dist");
|
15
|
-
const
|
16
|
-
return { sourceDir, packagePath, outDir,
|
15
|
+
const outBinsDir = myResolve(outDir, "__bin__");
|
16
|
+
return { sourceDir, packagePath, outDir, outBinsDir };
|
17
17
|
}
|
18
18
|
export {
|
19
19
|
resolveDirs
|
@@ -7,9 +7,13 @@ const utils = require("./utils.cjs");
|
|
7
7
|
async function binsTask({
|
8
8
|
buildOutput,
|
9
9
|
bins,
|
10
|
-
|
10
|
+
outBinsDir,
|
11
11
|
outDir
|
12
12
|
}) {
|
13
|
+
if (bins.size === 0) {
|
14
|
+
return /* @__PURE__ */ new Map();
|
15
|
+
}
|
16
|
+
await fs.mkdir(outBinsDir, { recursive: true });
|
13
17
|
const reversedEntrypoints = utils.reverseMap(bins);
|
14
18
|
const res = /* @__PURE__ */ new Map();
|
15
19
|
for (const el of buildOutput) {
|
@@ -24,8 +28,8 @@ async function binsTask({
|
|
24
28
|
continue;
|
25
29
|
}
|
26
30
|
for (const path$1 of binsPath) {
|
27
|
-
const totalPath = path.relative(
|
28
|
-
const execPath = path.join(
|
31
|
+
const totalPath = path.relative(outBinsDir, path.join(outDir, el.fileName));
|
32
|
+
const execPath = path.join(outBinsDir, path$1);
|
29
33
|
await fs.writeFile(
|
30
34
|
execPath,
|
31
35
|
`#!/usr/bin/env node
|
@@ -1,13 +1,17 @@
|
|
1
|
-
import { writeFile } from "node:fs/promises";
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
2
2
|
import { relative, join } from "node:path";
|
3
3
|
import "vite";
|
4
4
|
import { reverseMap } from "./utils.js";
|
5
5
|
async function binsTask({
|
6
6
|
buildOutput,
|
7
7
|
bins,
|
8
|
-
|
8
|
+
outBinsDir,
|
9
9
|
outDir
|
10
10
|
}) {
|
11
|
+
if (bins.size === 0) {
|
12
|
+
return /* @__PURE__ */ new Map();
|
13
|
+
}
|
14
|
+
await mkdir(outBinsDir, { recursive: true });
|
11
15
|
const reversedEntrypoints = reverseMap(bins);
|
12
16
|
const res = /* @__PURE__ */ new Map();
|
13
17
|
for (const el of buildOutput) {
|
@@ -22,8 +26,8 @@ async function binsTask({
|
|
22
26
|
continue;
|
23
27
|
}
|
24
28
|
for (const path of binsPath) {
|
25
|
-
const totalPath = relative(
|
26
|
-
const execPath = join(
|
29
|
+
const totalPath = relative(outBinsDir, join(outDir, el.fileName));
|
30
|
+
const execPath = join(outBinsDir, path);
|
27
31
|
await writeFile(
|
28
32
|
execPath,
|
29
33
|
`#!/usr/bin/env node
|
package/package.json
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "smartbundle",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.7.
|
4
|
+
"version": "0.7.2",
|
5
5
|
"bin": {
|
6
|
-
"smartbundle": "
|
6
|
+
"smartbundle": "__bin__/smartbundle"
|
7
7
|
},
|
8
8
|
"types": "./src/index.d.ts",
|
9
9
|
"module": "./src/index.js",
|
package/src/index.cjs
CHANGED
@@ -18,10 +18,9 @@ function setExports(exportsMap, exportName, mapFn) {
|
|
18
18
|
}
|
19
19
|
async function defineViteConfig(args = {}) {
|
20
20
|
const dirs = resolveDirs.resolveDirs(args);
|
21
|
-
const { sourceDir, outDir, packagePath
|
21
|
+
const { sourceDir, outDir, packagePath } = dirs;
|
22
22
|
await fs.rm(outDir, { recursive: true, force: true });
|
23
23
|
await fs.mkdir(outDir, { recursive: true });
|
24
|
-
await fs.mkdir(outInternalsDir, { recursive: true });
|
25
24
|
const packageJson$1 = await packageJson.parsePackageJson({ sourceDir, packagePath });
|
26
25
|
if (Array.isArray(packageJson$1)) {
|
27
26
|
console.error(packageJson$1);
|
@@ -32,7 +31,7 @@ async function defineViteConfig(args = {}) {
|
|
32
31
|
}
|
33
32
|
async function run(args) {
|
34
33
|
const dirs = resolveDirs.resolveDirs(args);
|
35
|
-
const { sourceDir, outDir, packagePath,
|
34
|
+
const { sourceDir, outDir, packagePath, outBinsDir } = dirs;
|
36
35
|
await fs.rm(outDir, { recursive: true, force: true });
|
37
36
|
await fs.mkdir(outDir, { recursive: true });
|
38
37
|
const packageJson$1 = await packageJson.parsePackageJson({ sourceDir, packagePath });
|
@@ -48,7 +47,6 @@ async function run(args) {
|
|
48
47
|
if (outputs.error) {
|
49
48
|
return { error: true, errors: outputs.errors };
|
50
49
|
}
|
51
|
-
await fs.mkdir(outInternalsDir, { recursive: true });
|
52
50
|
const viteOutput = outputs.output;
|
53
51
|
const exportsMap = /* @__PURE__ */ new Map();
|
54
52
|
const binsMap = /* @__PURE__ */ new Map();
|
@@ -80,7 +78,7 @@ async function run(args) {
|
|
80
78
|
});
|
81
79
|
}
|
82
80
|
}),
|
83
|
-
binsTask.binsTask({
|
81
|
+
binsTask.binsTask({ outBinsDir, bins, buildOutput: viteOutput, outDir }).then(
|
84
82
|
(res) => {
|
85
83
|
for (const [value, key] of res) {
|
86
84
|
binsMap.set(key, value);
|
package/src/index.js
CHANGED
@@ -16,10 +16,9 @@ function setExports(exportsMap, exportName, mapFn) {
|
|
16
16
|
}
|
17
17
|
async function defineViteConfig(args = {}) {
|
18
18
|
const dirs = resolveDirs(args);
|
19
|
-
const { sourceDir, outDir, packagePath
|
19
|
+
const { sourceDir, outDir, packagePath } = dirs;
|
20
20
|
await rm(outDir, { recursive: true, force: true });
|
21
21
|
await mkdir(outDir, { recursive: true });
|
22
|
-
await mkdir(outInternalsDir, { recursive: true });
|
23
22
|
const packageJson = await parsePackageJson({ sourceDir, packagePath });
|
24
23
|
if (Array.isArray(packageJson)) {
|
25
24
|
console.error(packageJson);
|
@@ -30,7 +29,7 @@ async function defineViteConfig(args = {}) {
|
|
30
29
|
}
|
31
30
|
async function run(args) {
|
32
31
|
const dirs = resolveDirs(args);
|
33
|
-
const { sourceDir, outDir, packagePath,
|
32
|
+
const { sourceDir, outDir, packagePath, outBinsDir } = dirs;
|
34
33
|
await rm(outDir, { recursive: true, force: true });
|
35
34
|
await mkdir(outDir, { recursive: true });
|
36
35
|
const packageJson = await parsePackageJson({ sourceDir, packagePath });
|
@@ -46,7 +45,6 @@ async function run(args) {
|
|
46
45
|
if (outputs.error) {
|
47
46
|
return { error: true, errors: outputs.errors };
|
48
47
|
}
|
49
|
-
await mkdir(outInternalsDir, { recursive: true });
|
50
48
|
const viteOutput = outputs.output;
|
51
49
|
const exportsMap = /* @__PURE__ */ new Map();
|
52
50
|
const binsMap = /* @__PURE__ */ new Map();
|
@@ -78,7 +76,7 @@ async function run(args) {
|
|
78
76
|
});
|
79
77
|
}
|
80
78
|
}),
|
81
|
-
binsTask({
|
79
|
+
binsTask({ outBinsDir, bins, buildOutput: viteOutput, outDir }).then(
|
82
80
|
(res) => {
|
83
81
|
for (const [value, key] of res) {
|
84
82
|
binsMap.set(key, value);
|
package/src/resolveDirs.d.ts
CHANGED
package/src/tasks/binsTask.d.ts
CHANGED
@@ -2,8 +2,8 @@ import { type Rollup } from "vite";
|
|
2
2
|
type BinsTaskOption = {
|
3
3
|
buildOutput: Rollup.OutputChunk[];
|
4
4
|
bins: Map<string, string>;
|
5
|
-
|
5
|
+
outBinsDir: string;
|
6
6
|
outDir: string;
|
7
7
|
};
|
8
|
-
export declare function binsTask({ buildOutput, bins,
|
8
|
+
export declare function binsTask({ buildOutput, bins, outBinsDir, outDir, }: BinsTaskOption): Promise<Map<string, string>>;
|
9
9
|
export {};
|
File without changes
|