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

Bundle compatibility: .contrast is not a function, .deltaE is not a function #235

Closed
ambar opened this issue Nov 3, 2022 · 2 comments · Fixed by #239
Closed

Bundle compatibility: .contrast is not a function, .deltaE is not a function #235

ambar opened this issue Nov 3, 2022 · 2 comments · Fixed by #239

Comments

@ambar
Copy link
Contributor

ambar commented Nov 3, 2022

Bug

Using vite@3.2.2 or esbuild@0.15.12

Reproduce

input.js

import Color from 'colorjs.io'

const red = new Color('red')
const blue = new Color('blue')

// ERROR: .contrast is not a function
red.contrast(blue, 'WCAG21')
// ERROR: .deltaE is not a function
red.deltaE(blue, '2000')

// PASSED
// red.contrastWCAG21(blue)
// red.deltaE2000(blue)

bundle:

esbuild --bundle --minify input.js --outfile=bundle.js && node bundle.js
@jgerigmeyer
Copy link
Member

jgerigmeyer commented Nov 4, 2022

@ambar Thanks for reporting -- I can reproduce this error using esbuild@0.15.12 (though I can't reproduce it using vite@3.2.2). During minification, esbuild by default renames function names, and colorjs.io relies upon function names in its default package export. You can disable the esbuild feature by adding --keep-names to your command:

esbuild --bundle --minify --keep-names input.js --outfile=bundle.js && node bundle.js

@ambar
Copy link
Contributor Author

ambar commented Nov 5, 2022

@jgerigmeyer You should run vite build to verify bundled result.

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 a pull request may close this issue.

2 participants