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

fix: oom #329 #330

Merged
merged 3 commits into from
May 24, 2023
Merged

fix: oom #329 #330

merged 3 commits into from
May 24, 2023

Conversation

tjx666
Copy link
Contributor

@tjx666 tjx666 commented May 23, 2023

for given workspaces config:

{
	"workspace": [ "packages/**" ]
}

should only search fastGlob('packages/**/package.json') instead of fastGlob('packages/**')

close #329

close un-ts/synckit#134

close ota-meshi/eslint-plugin-json-schema-validator#220

@stackblitz
Copy link

stackblitz bot commented May 23, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot
Copy link

changeset-bot bot commented May 23, 2023

🦋 Changeset detected

Latest commit: 8434558

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@pkgr/rollup Patch
@pkgr/utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 23, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@JounQin
Copy link
Member

JounQin commented May 23, 2023

tryGlob is not only used for searching package.json, this PR is a breaking change for other common usage of this function.

A better solution is needed.

(And to myself: it seems a bad practice to execute these configs too earlier, they're not always used actually 😂

@tjx666
Copy link
Contributor Author

tjx666 commented May 23, 2023

And this package also not support pnpm, forget to consider pnpm-workspace.yaml

@tjx666
Copy link
Contributor Author

tjx666 commented May 23, 2023

export const monorepoPkgs = isMonorepo ? tryGlob(pkgsPath) : []

should consider changed to:

export const getMonorepoPkgs = () => isMonorepo ? tryGlob(pkgsPath) : []

@tjx666
Copy link
Contributor Author

tjx666 commented May 23, 2023

seems fnm doesn't support current .nvmrc version format used in this package:

image

@tjx666
Copy link
Contributor Author

tjx666 commented May 23, 2023

When I use changeset, report error:

image

@tjx666
Copy link
Contributor Author

tjx666 commented May 23, 2023

Seems lost simple-git-hooks config:

image

@tjx666
Copy link
Contributor Author

tjx666 commented May 23, 2023

@JounQin But seems the variable name means to find packages in monorepo https://github.com/un-ts/pkgr/blob/master/packages/utils/src/monorepo.ts#LL15C64-L15C64

export const isMonorepo = Array.isArray(pkgsPath) && pkgsPath.length > 0

export const monorepoPkgs = isMonorepo ? tryGlob(pkgsPath) : []

@JounQin
Copy link
Member

JounQin commented May 23, 2023

You may need to build before committing. @pkgr/utils is used inside many of my packages, so non-built ts source files in this repo will not work.

@JounQin
Copy link
Member

JounQin commented May 23, 2023

@JounQin But seems the variable name means to find packages in monorepo https://github.com/un-ts/pkgr/blob/master/packages/utils/src/monorepo.ts#LL15C64-L15C64

export const isMonorepo = Array.isArray(pkgsPath) && pkgsPath.length > 0

export const monorepoPkgs = isMonorepo ? tryGlob(pkgsPath) : []

So package.json should be added at that line.

@tjx666
Copy link
Contributor Author

tjx666 commented May 23, 2023

我总结一下我主要关心的点:

  1. 如你所说不应该提前获取配置,尤其是这种可能耗时比较多的,也就是 monorepoPkgs 应该改成 getMonorepoPkgs
  2. 搜索一个 monorepo 里面有哪些 packages 应该是搜索 package.json 文件,此外考虑是否需要处理类似 pnpm-workspace.yaml 中支持的例如 !xxx/yyy 这种 negative glob
  3. 目前没有支持 pnpm,pnpm worksapce 会被识别为非 monorepo,如果要获取 pnpm 的 packages 建议用 pnpm 官方的 @pnpm/find-workspace-packages

总的来说,如果有现成的成熟的第三方库,考虑使用库而不是自己写

@JounQin
Copy link
Member

JounQin commented May 23, 2023

谢谢建议,明天会先弄个小的 patch fix,后面大版本改成更合理的方式。

@JounQin JounQin merged commit 52c7f39 into un-ts:master May 24, 2023
@tjx666
Copy link
Contributor Author

tjx666 commented May 24, 2023

看了一下最新代码,我感觉查找 package.json 时 fast-glob 用 onlyFiles: true 性能会更好

@JounQin
Copy link
Member

JounQin commented Dec 26, 2023

看了一下最新代码,我感觉查找 package.json 时 fast-glob 用 onlyFiles: true 性能会更好

@tjx666 如果能提个 PR 就更好了,哈哈哈


目前没有支持 pnpm,pnpm worksapce 会被识别为非 monorepo,如果要获取 pnpm 的 packages 建议用 pnpm 官方的 @pnpm/find-workspace-packages

总的来说,如果有现成的成熟的第三方库,考虑使用库而不是自己写

这个包的主要用户是我自己,所以搜索相关配置是按我个人习惯实现的,这也是为啥所有包目前没有 README。
之前带来一些副作用引用了其他包确实是 unexpected,而引入第三方库会增加不必要的复杂度和包体积。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

oom issue caused by @pkgr/utils [oom] out of memory [oom] out of memory
2 participants