Comments (5)
Hi @VojtechVidra! What seems to be going on is some unintended tree-shaking of the ESM entry point src/index.js
when you import something that the bundler deems to be free of side-effects.
Importing just converter
seems to skip all the side-effects further down in the file:
import { converter } from "culori";
If instead you import the LCh converter directly, which is defined as a side-effect in the entry point, all the other side effects are executed and the code works:
import { lch } from 'culori';
If I understand correctly, Next.js 13 uses Turbopack, so that may be the place to open up an issue. I misread that, Next.js 13 uses a built-in Compiler, so the Next.js repo may be the place to log the issue. It feels to me like overeager tree-shaking. Admittedly, the way Culori is organized is a bit quirky!
This is not a problem for the CommonJS bundle because tree-shaking is not applicable there.
from culori.
In [email protected]
I've replaced sideEffects: false
with an array of files producing side effects. This should allow both the tree-shaken version (using culori/fn
) and the non-tree-shaken version to work correctly with more bundlers.
Tested the files in test/tree-shaking/
with esbuild, rollup, and parcel. Let me know how this new setup works for you!
from culori.
I just updated to 3.1.2 and can confirm the build is working as expected in a Svelte app.
Thanks @danburzo , you rock dude.
from culori.
The issue may be caused by our usage of sideEffects: false;
in package.json
, which if I remember correctly was necessary in order to allow for tree-shaking ESM modules. I'm going to leave the issue open as we may want to revisit this value in the future, to offer better support for the various bundlers.
from culori.
The issue may be caused by our usage of
sideEffects: false;
inpackage.json
, which if I remember correctly was necessary in order to allow for tree-shaking ESM modules. I'm going to leave the issue open as we may want to revisit this value in the future, to offer better support for the various bundlers.
I confirm this.
Same thing happens when creating a build with Svelte.
Local dev environment works as expected, whereas when creating a build I get some sort of error which traces back to the interpolate function.
I manually removed "sideEffects": false, from the package.json of culori and the build works fine afterwards.
from culori.
Related Issues (20)
- `lch()` and `lab()` in `formatCss` has no `%` HOT 3
- Bug in displayable() in oklch HOT 3
- culori.d.ts - Is there an updated type declaration file to use with TypeScript? HOT 1
- Implement parse-time clamping of L lab/oklab/lch/oklch
- XYB: is the Chroma from Luma adjustment correction really in the JXL implementation? HOT 2
- Interpolator throwing a NaN/undefined HOT 4
- Library-wide handling of missing and powerless components HOT 2
- Endless loop when using a double point HOT 2
- Add RYB colors HOT 19
- mix() function, and 2d/3d counterparts
- Dead link in docs HOT 1
- Precise chroma clamping in P3 color space HOT 2
- Suggestion to specify target gamut for clampChroma() HOT 1
- Provide ability to tree-shake parsers. HOT 2
- Adjust <number> parsing in HSL / HWB / etc(?) modern syntaxes to appropriate component ranges
- `'culori/fn'` regression in 4.0 HOT 3
- Switch tests from `tape` to native Node test runner
- Addition of CMYK color space HOT 1
- Add DIN99c/d color space HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from culori.