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 bundler compatibility #239

Merged
merged 1 commit into from
Nov 8, 2022

Conversation

ambar
Copy link
Contributor

@ambar ambar commented Nov 5, 2022

Fixes #235

It's not safe to access function name in bundled apps, such as (reproduced in):

  • vite@3.2.2 / esbuild@0.15.12
  • cra@5.0.1 / terser@5.15.1
  • next@13.0.1 / swc@1.2

This bug could also reproduced in dist/color.global.min.js (main branch, bundled by terser):

// eval dist/color.global.min.js 
Color.prototype.contrast -> undefined

@LeaVerou
Copy link
Member

LeaVerou commented Nov 5, 2022

I'm fine to make the change, though I think it's a bug in these tools if they mess up func.name. But are you sure the only calls affected are these two? I'd expect it's a lot more. I need some time to look through the codebase to make sure there aren't more.

@ambar
Copy link
Contributor Author

ambar commented Nov 5, 2022

I've checked all prototype properties, there're only two properties that got renamed:

image

@LeaVerou
Copy link
Member

LeaVerou commented Nov 6, 2022

@jgerigmeyer what do you think? Fine to merge if it LGTY.

@jgerigmeyer
Copy link
Member

Looks good on a quick skim, but I'd be happy to take a closer look tomorrow. 👍🏻

Copy link
Member

@jgerigmeyer jgerigmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ambar Looks good! Thanks for this contribution. 🚀

One minor request, then this is ready to merge.

src/color.js Show resolved Hide resolved
src/color.js Show resolved Hide resolved
@jgerigmeyer jgerigmeyer merged commit 288511f into color-js:main Nov 8, 2022
@carlobeltrame
Copy link

Thanks for the fix! Can we get a release which includes this?

carlobeltrame added a commit to carlobeltrame/ecamp3 that referenced this pull request Nov 9, 2022
colorjs.io is currently incompatible with bundlers.
See color-js/color.js#239
Remove this postinstall script once we upgrade to a version which
includes that PR.
@LeaVerou
Copy link
Member

Will try to do that tomorrow!

@carlobeltrame
Copy link

Ping: We would still be happy about a release including this fix. Thanks for your efforts!

@LeaVerou
Copy link
Member

Done! Sorry I dropped the ball last week.

f2c-ci-robot bot pushed a commit to halo-dev/console that referenced this pull request Nov 28, 2022
…#721)

#### What type of PR is this?

/kind feature
/milestone 2.0.0-rc.2

#### What this PR does / why we need it:

添加自动计算文章标签文字颜色的支持。在之前的版本中,因为引入 colorjs.io 导致在构建之后无法显示标签,目前 colorjs.io 已经修复此问题,此 PR 回归之前的支持。

- https://github.com/LeaVerou/color.js/releases/tag/v0.4.2
- color-js/color.js#239

#### Special notes for your reviewer:

测试方式:

1. 创建若干文章标签,设置不同的背景色,观察文字颜色是否会自动与背景颜色形成反差。
2. 使用 `pnpm build` 构建生产版本,在 Halo 的配置文件中配置 `halo.console.location` 到 Console 的 `dist` 目录。
3. 检查 Console 文章列表中的标签是否显示正常。

#### Does this PR introduce a user-facing change?


```release-note
Console 端添加自动计算文章标签文字颜色的支持。
```
JohnNiang pushed a commit to JohnNiang/halo that referenced this pull request Mar 2, 2023
…halo-dev/console#721)

#### What type of PR is this?

/kind feature
/milestone 2.0.0-rc.2

#### What this PR does / why we need it:

添加自动计算文章标签文字颜色的支持。在之前的版本中,因为引入 colorjs.io 导致在构建之后无法显示标签,目前 colorjs.io 已经修复此问题,此 PR 回归之前的支持。

- https://github.com/LeaVerou/color.js/releases/tag/v0.4.2
- color-js/color.js#239

#### Special notes for your reviewer:

测试方式:

1. 创建若干文章标签,设置不同的背景色,观察文字颜色是否会自动与背景颜色形成反差。
2. 使用 `pnpm build` 构建生产版本,在 Halo 的配置文件中配置 `halo.console.location` 到 Console 的 `dist` 目录。
3. 检查 Console 文章列表中的标签是否显示正常。

#### Does this PR introduce a user-facing change?


```release-note
Console 端添加自动计算文章标签文字颜色的支持。
```
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.

Bundle compatibility: .contrast is not a function, .deltaE is not a function
4 participants