Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress the published package fec-builder #159

Open
nighca opened this issue Jan 11, 2022 · 1 comment
Open

Compress the published package fec-builder #159

nighca opened this issue Jan 11, 2022 · 1 comment
Assignees

Comments

@nighca
Copy link
Collaborator

nighca commented Jan 11, 2022

With tools like vercel/ncc

@nighca nighca self-assigned this Jan 11, 2022
@nighca nighca changed the title Compress publish content Compress published content Jan 11, 2022
@nighca
Copy link
Collaborator Author

nighca commented Jan 30, 2022

简单尝试了下,目前主要的障碍在:

  1. 依赖 __dirname / __filename 的代码(如读取 preset config 的逻辑)会行为不正确(代码被 bundle 了)

    可以考虑通过获取 package (builder) root,然后往 package root 后边拼路径的方式来定位目标资源(如 preset config)

    获取 package root 可以通过从当前文件路径向上找,直到找到最近的、包含 package.json 文件的路径来实现;不过需要注意,ncc 构建出的 dist/ 目录中也是有 package.json 文件的,因此这个做法会有问题

  2. 依赖 require.resolve 获取某个依赖(如 webpack loader 或 babel preset)的绝对路径的逻辑会不正确(依赖被 bundle 了)

    考虑把这些依赖加到 ncc externals 里(跟着 builder 一起被安装);或者放到特定的目录里,通过拼接该特定目录来代替 require.resolve 逻辑

  3. 依赖中存在类似 1 / 2 的逻辑

@nighca nighca changed the title Compress published content Compress the published package fec-builder May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant