-
Notifications
You must be signed in to change notification settings - Fork 16
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
Build issue for scheduler import, with Vite #289
Comments
Which version of cron-schedule, node, and typescript are you using? |
My last try was with 4.0.0-next.3, though I’ll double check to see what actually got installed. |
I have created a sample project which also shows the same issue: https://github.com/ajmas/vue-cron-sample The You can see the behaviour on Hopefully this helps you investigate. |
So investigation shows that Typescript doesn't deal with package exports too well. What I ended up doing in a local checkout of import { TimerBasedCronScheduler } from './schedulers/timer-based.js'
import { IntervalBasedCronScheduler } from './schedulers/interval-based.js'
export * from './cron-parser.js'
export * from './cron.js'
export { TimerBasedCronScheduler, IntervalBasedCronScheduler } With my Vite based Vue project, only the |
Have you tried |
I tried a lot of things, include that. It creates other breakages. BTW If anyone else sees this issue and can show by demonstration of a change to https://github.com/ajmas/vue-cron-sample makes this work, then I would be interested to know what you did. Short term I am tempted to fork this project, and make the indicated changes, since I can't use it otherwise. Once Typescript finally addresses this then I can look to going back to the main fork. Right now this is a blocker in our project. We have already spent too may hours on this, so we are opting for the easy way out. |
I just saw that "./vite": {
"require": "./lib/vite.cjs",
"import": "./lib/vite.mjs",
"types": "./vite.d.ts"
} I'll need to explore some more here, to see how it creates its distributables and then see if I can apply the same here? Following the recipe here provided a working solution: https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html I'll create a PR for you to review. |
I got this problem also this pr will fix #295 |
In order to use this package, you need to use moduleResolution node16 or nodenext. |
Hi - I have went through a fantastic journey to use this library. I straightened out my tsconfig, upgraded to TS 5, and switched to ESM (I must use in-browser). I will document it here in case it helps someone. I would like to point out that the 2022 pull request for the linked issue directly contradicts the comment about tsconfig
It appears package exports have been available for TS since TS 4.7 using Important settings are also detailed. They have favorable defaults, don't worry about them.
Finally, ESLint plugin import "import/no-unresolved": ["error", { "ignore": "cron-schedule.*" }], |
The documentation indicates the following for the import for the scheduler:
Though when I do this in VS Code it says it cant' find it. The following works though, but then breaks in execution of the app:
Originally I though this was a documentation issue, but now I am wondering whether the packaging has some issues, since if I use
cron-schedule/schedulers/interval-based.js
dev runtime works, build build time fails.Error output:
My import is presented as follows in my Vue file:
I am using Vite 3.2.3 for packaging.
Looking at issue #284, but
yarn add [email protected] -S
didn't change anything.The text was updated successfully, but these errors were encountered: