tshy-after
Version:
Auto set package.json after tshy run
52 lines (35 loc) • 1.6 kB
Markdown
# tshy-after
[![NPM version][npm-image]][npm-url]
[](https://github.com/node-modules/tshy-after/actions/workflows/nodejs.yml)
[![npm download][download-image]][download-url]
[](https://nodejs.org/en/download/)
[](https://makeapullrequest.com)
[npm-image]: https://img.shields.io/npm/v/tshy-after.svg?style=flat-square
[npm-url]: https://npmjs.org/package/tshy-after
[download-image]: https://img.shields.io/npm/dm/tshy-after.svg?style=flat-square
[download-url]: https://npmjs.org/package/tshy-after
Auto set package.json after [tshy](https://github.com/isaacs/tshy) run
## keep `types`
Set `package.types` to `package.exports['.'].require.types`
## Auto fix `import.meta.url` and `import.meta.resolve` SyntaxError on CJS
```bash
SyntaxError: Cannot use 'import.meta' outside a module
```
e.g.: Get the file's dirname
```ts
// src/index.ts
import { fileURLToPath } from 'node:url';
import path from 'node:path';
export function getDirname() {
if (typeof __dirname !== 'undefined') {
return __dirname;
}
// @ts-ignore
return path.dirname(fileURLToPath(import.meta.url));
}
```
## License
[MIT](LICENSE)
## Contributors
[](https://github.com/node-modules/tshy-after/graphs/contributors)
Made with [contributors-img](https://contrib.rocks).