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

Date libraries are not optional when using @salt-ds/date-adapters with Vite #4468

Open
4 of 11 tasks
origami-z opened this issue Dec 2, 2024 · 1 comment · May be fixed by #4471
Open
4 of 11 tasks

Date libraries are not optional when using @salt-ds/date-adapters with Vite #4468

origami-z opened this issue Dec 2, 2024 · 1 comment · May be fixed by #4471
Labels
package: date-adapters status: awaiting triage Automatically added to new issues. Should be removed once they have been triaged. type: bug 🪲 Something isn't working

Comments

@origami-z
Copy link
Contributor

Latest version

  • I have tested the latest version

Description

When using new lab v56 of date picker with @salt-ds/date-adapters, Vite will fail running local server while trying to resolve all date libraries

Steps to reproduce

Use Vite TS template, install Salt packages with date-fns only (one of 4 date packages), run npm run dev, error below

Plugin: vite:import-analysis
File: xxxxxx/node_modules/.vite/deps/chunk-DZFYDRDP.js?v=a34e13b6:32087:27
32085|
32086| // node_modules/@salt-ds/date-adapters/dist-es/dayjs/index.js
32087| import defaultDayjs from "dayjs";


Also tried below vite setting, without any luck

optimizeDeps: {
    exclude: ["dayjs", "luxon", "moment", "moment-timezone"],
  },

According to this vite issue, only way to make it work would be not importing it.

Expected behavior

Only required package should be imported, maybe split 4 adapters into different entry point would work?

Package name(s)

Lab (@salt-ds/lab)

Package version(s)

"@salt-ds/lab": "1.0.0-alpha.56"

Browser

  • Chrome
  • Safari
  • Firefox
  • Microsoft Edge

Operating system

  • macOS
  • Windows
  • Linux
  • iOS
  • Android

Are you a JPMorgan Chase & Co. employee?

  • I am an employee of JPMorgan Chase & Co.
@origami-z origami-z added type: bug 🪲 Something isn't working status: awaiting triage Automatically added to new issues. Should be removed once they have been triaged. package: date-adapters labels Dec 2, 2024
@origami-z
Copy link
Contributor Author

origami-z commented Dec 2, 2024

Looks like the build script needs to be updated to support multiple entries

const bundle = await rollup({
input: path.join(cwd, "src/index.ts"),

https://rollupjs.org/configuration-options/#input

exports may potential work, but it's not supported by typescript yet..? https://nodejs.org/api/packages.html#package-entry-points

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: date-adapters status: awaiting triage Automatically added to new issues. Should be removed once they have been triaged. type: bug 🪲 Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

1 participant