Skip to content

Commit

Permalink
feat(monobundle): drop d.ts gen
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Mar 13, 2024
1 parent 62e5b0f commit c52ac4f
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 180 deletions.
Binary file modified bun.lockb
Binary file not shown.
8 changes: 3 additions & 5 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.12.1",
"version": "0.13.0",
"monobundle": {
"exports": {
".": "./src/index.ts",
Expand All @@ -20,8 +20,7 @@
"globby": "^14.0.1",
"js-yaml": "^4.1.0",
"minimatch": "^9.0.3",
"rollup": "^4.12.0",
"rollup-plugin-dts": "^6.1.0",
"rollup": "^4.13.0",
"yargs": "^17.7.2"
},
"peerDependencies": {
Expand All @@ -38,14 +37,13 @@
".": {
"bun": "./src/index.ts",
"import": {
"types": "./index.d.ts",
"types": "./src/index.ts",
"default": "./index.mjs"
}
}
},
"files": [
"*.mjs",
"*.d.ts",
"src/*",
"!/**/__tests__"
],
Expand Down
64 changes: 32 additions & 32 deletions nodedevpkg/monobundle/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Project } from "./pm";
import {
type MonoBundleOptions,
entryAlias,
writeFormattedJsonFile,
writeFormattedJsonFile
} from "./util";

const imlFromPackageJSON = (rpath: string, pkg: any) => {
Expand All @@ -17,7 +17,7 @@ const imlFromPackageJSON = (rpath: string, pkg: any) => {

const patchRootPackage = async (
project: Project,
pkgs: { [k: string]: any },
pkgs: { [k: string]: any }
) => {
await writeFile(
join(project.root, ".idea/modules.xml"),
Expand All @@ -26,16 +26,16 @@ const patchRootPackage = async (
<component name="ProjectModuleManager">
<modules>
${map(pkgs, (pkg, dir) => {
const filename = join(
"$PROJECT_DIR$",
imlFromPackageJSON(relative(project.root, dir), pkg),
);
return `<module fileurl="file://${filename}" filepath="${filename}" />`;
}).join("\n")}
const filename = join(
"$PROJECT_DIR$",
imlFromPackageJSON(relative(project.root, dir), pkg)
);
return `<module fileurl="file://${filename}" filepath="${filename}" />`;
}).join("\n")}
</modules>
</component>
</project>
`,
`
);
};

Expand All @@ -47,7 +47,7 @@ const orderKeys = <T extends {}>(o: T) => {
"dependencies",
"peerDependencies",
"devDependencies",
...keys(o).sort(),
...keys(o).sort()
];
return pick(o, orderedKeys);
};
Expand All @@ -67,9 +67,9 @@ const getExportsAndBin = (options?: MonoBundleOptions) => {
// bun must on first
bun: entryFile,
import: {
types: `./${distName}.d.ts`,
default: `./${distName}.mjs`,
},
types: `${entryFile}`,
default: `./${distName}.mjs`
}
});
});

Expand All @@ -81,19 +81,19 @@ const patchMonoPackage = async (
monoRoot: string,
directory: string,
pkg: any,
rootPkg: any,
rootPkg: any
) => {
const defaultScripts = project.pm.defaults().scripts;

const scripts = {
...(pkg.scripts || {}),
...(pkg.scripts || {})
};

if (get(pkg, ["monobundle"])) {
scripts.lint = get(
pkg,
["monobundle", "pipeline", "lint"],
defaultScripts.lint,
defaultScripts.lint
);
scripts.build =
get(pkg, ["monobundle", "pipeline", "build"], defaultScripts.build) ||
Expand All @@ -118,17 +118,17 @@ const patchMonoPackage = async (
license: "MIT",
repository: rootPkg.repository
? {
...rootPkg.repository,
directory,
}
...rootPkg.repository,
directory
}
: undefined,
publishConfig:
!pkg.private && rootPkg.publishConfig
? {
...rootPkg.publishConfig,
}
: undefined,
}),
...rootPkg.publishConfig
}
: undefined
})
);
};

Expand All @@ -150,17 +150,17 @@ export const addImiFile = async (monoRoot: string, pkg: any) => {
<excludeFolder url="file://$MODULE_DIR$/.build" />
<excludeFolder url="file://$MODULE_DIR$/dist" />
${
isCueMod
? `
isCueMod
? `
<excludeFolder url="file://$MODULE_DIR$/cue.mod/gen" />
<excludeFolder url="file://$MODULE_DIR$/cue.mod/pkg" />
`
: ""
}
: ""
}
</content>
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>`,
</module>`
);
};

Expand All @@ -174,12 +174,12 @@ export const bootstrap = async (project: Project) => {
const packageJsonFiles = await globby(
[
`${project.root}/package.json`,
...workspaces.map((p) => `${p}/package.json`),
...workspaces.map((p) => `${p}/package.json`)
],
{
cwd: project.root,
absolute: true,
},
absolute: true
}
);

const packages: { [k: string]: any } = {};
Expand All @@ -198,7 +198,7 @@ export const bootstrap = async (project: Project) => {
monoRoot,
rpath,
packageJSON,
packages[""],
packages[""]
);
}

Expand Down
Loading

0 comments on commit c52ac4f

Please sign in to comment.