Skip to content

Commit

Permalink
fix(monobundle): generated code could be under dist
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Mar 13, 2024
1 parent cffe425 commit 289650d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ ship:
clean:
find . -name '.turbo' -type d -prune -print -exec rm -rf '{}' \;
find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
rm -f bun.lockb
Binary file modified bun.lockb
Binary file not shown.
8 changes: 4 additions & 4 deletions nodedevpkg/monobundle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@innoai-tech/monobundle",
"version": "0.13.3",
"version": "0.13.4",
"monobundle": {
"exports": {
".": "./src/index.ts",
Expand Down Expand Up @@ -31,18 +31,18 @@
"@types/yargs": "^17.0.32"
},
"bin": {
"monobundle": "./monobundle.mjs"
"monobundle": "./dist/monobundle.mjs"
},
"exports": {
".": {
"import": {
"types": "./src/index.ts",
"default": "./index.mjs"
"default": "./dist/index.mjs"
}
}
},
"files": [
"*.mjs",
"dist/*",
"src/*",
"!/**/__tests__"
],
Expand Down
19 changes: 13 additions & 6 deletions nodedevpkg/monobundle/src/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const bundle = async ({
input: inputs,
output: {
...outputBase,
dir: "./dist",
entryFileNames: "[name].mjs",
chunkFileNames: "[name]-[hash].mjs"
},
Expand All @@ -113,8 +114,11 @@ export const bundle = async ({
}];

// cleanup

const files = await globby(["*.mjs", "*.d.ts"]);
const files = await globby([
"dist/*",
"*.mjs",
"*.d.ts"
]);
for (const f of files) {
await unlink(join(cwd, f));
}
Expand Down Expand Up @@ -175,8 +179,11 @@ export const bundle = async ({
devDependencies: isEmpty(pkg["devDependencies"])
? undefined
: (pkg["devDependencies"] as { [k: string]: string }),
files: ["*.mjs",
"src/*", "!/**/__tests__"],
files: [
"dist/*",
"src/*",
"!/**/__tests__"
],
// FIXME remote all old entries
types: undefined,
main: undefined,
Expand All @@ -196,14 +203,14 @@ const genExportsAndBin = (options?: MonoBundleOptions) => {
const distName = entryAlias(e);

if (startsWith(e, "bin:")) {
set(pkg, ["bin", distName], `./${distName}.mjs`);
set(pkg, ["bin", distName], `./dist/${distName}.mjs`);
return;
}

set(pkg, ["exports", e], {
import: {
types: `${entryFile}`,
default: `./${distName}.mjs`
default: `./dist/${distName}.mjs`
}
});
});
Expand Down

0 comments on commit 289650d

Please sign in to comment.