npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@build-script/export-all-in-one

v3.1.7

Published

write your library with typescript. make all exports available from single entry.

Downloads

37

Readme

English

export-all-in-one

在你的 TypeScript 项目中“收集”所有export语句,把它们从一个入口文件中重新导出,于是其他人可以import { 任何, 东西 } from '@你的/包'。而不需要了解任何东西在哪个文件里。你可以在不同版本间瞎几把改文件路径,没有人会察觉。

使用方法:

一、安装

npm -g install build-script

二、修改你的 tsconfig

由于种种限制,outDir 是必须的。不支持原地编译。

三、使用魔法

tsconfig.json 可以省略,这两个命令的先后顺序无所谓

export-all-in-one ./path/to/tsconfig.json
tsc -p ./path/to/tsconfig.json

💥BOOM,所有东西都导出了。

提示:

  1. 你还需要在package.json中设置入口文件
    这个工具会在你的outDir文件夹里创建_export_all_in_one_index.js,你需要把package.json中的main指向它。
  2. 同时还要改package.json中的 types 或 typings 字段,值为./docs/package-public.d.ts
  3. 当探测到“双包模式”时,这个工具同时还会创建_export_all_in_one_index.cjs,你需要修改package.json中的exports

链接:

选项与配置:

如果一个导出的符号有注释文档(/** */):

  • 带有@extern标签的会被导出
  • 带有@internal标签的会被隐藏(.d.ts 和_export_all_in_one_index 里都不会有它)
  • 没用注释,或没有上面两种标签:使用默认设置(exportEverything)

没有export的符号无论加什么都不会被导出。

package.json中的配置:

{
	"exportAllInOne": {
		"exportEverything": true
	}
}

| 配置 | 类型 | 默认值 | 描述 | | ---------------- | ------- | ------ | ---------------------------------------- | | exportEverything | boolean | true | 符号如果不加注释,默认应该被导出还是隐藏 |

这个包会做:

  1. 通过你的tsconfig.json和 typescript api 解析你项目涉及到的文件(所以不被 tsc 处理的文件也不会被这个包处理)
  2. 收集各个文件中导出的符号信息
  3. 在临时文件夹里生成一个_export_all_in_one_index.ts
  4. 调用和 typescript 编译_export_all_in_one_index.ts然后把结果复制到outDir
  5. 调用@microsoft/api-extractor分析_export_all_in_one_index.ts然后把结果复制到你的包/docs/

限制:

  1. 显然,你的多个文件不可以导出同一个名称,但你本来也不该这么做,除非你想让用户的 IDE 懵逼

  2. 默认导出会被变成命名导出,名称就是文件名(不建议用默认导出)