Skip to content

Commit

Permalink
Add typescript information for core-js-builder
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
  • Loading branch information
susnux committed Jan 3, 2023
1 parent d6f80e2 commit 4d91a8f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/core-js-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ const bundle = await builder({
filename: PATH_TO_MY_COREJS_BUNDLE,
});
```

ℹ️ When using TypeScript, make sure to set `esModuleInterop` to `true`.
33 changes: 33 additions & 0 deletions packages/core-js-builder/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
type Summary = {
size: boolean,
modules: boolean
};

type StringOrRegExp = string | RegExp;

type MinEnvTarget = Record<string, string | readonly string[]> | { esmodules?: boolean };

type Options = {
/** entry / module / namespace / an array of them, by default - all `core-js` modules */
modules?: StringOrRegExp | readonly StringOrRegExp[],
/** a blacklist of entries / modules / namespaces, by default - empty list */
exclude?: StringOrRegExp | readonly StringOrRegExp[],
/** optional browserslist or core-js-compat format query */
targets?: string | readonly string[] | MinEnvTarget,
/** output format, 'bundle' by default, can be 'cjs' or 'esm', and in this case
* the result will not be bundled and will contain imports of required modules */
format?: 'bundle' | 'esm' | 'cjs',
/** optional target filename, if it's missed a file will not be created */
filename?: string,
/** shows summary for the bundle, disabled by default */
summary?: {
/** in the console, you could specify required parts or set `true` for enable all of them */
comment?: Summary,
/** in the comment in the target file, similarly to `summary.console` */
console?: Summary,
}
};

declare function builder(options: Options): Promise<string>;

export = builder;
1 change: 1 addition & 0 deletions packages/core-js-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"sideEffects": false,
"main": "index.js",
"types": "index.d.ts",
"dependencies": {
"core-js": "3.27.1",
"core-js-compat": "3.27.1",
Expand Down

0 comments on commit 4d91a8f

Please sign in to comment.