P4sca1 / cron-schedule

A zero-dependency cron parser and scheduler for Node.js, Deno and the browser.
MIT License
177 stars 15 forks source link

fix: export interval based and timer based on index #295

Closed ntsd closed 1 year ago

ntsd commented 1 year ago

ref: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#main

P4sca1 commented 1 year ago

Hey @ntsd, thank you for your contribution. The schedulers intentionally got removed from the main file to keep the bundle size low, which is especially important when using this library in the browser and only parsing cron expressions. Could you share your setup and the issues you are facing with importing the schedulers individually?

ntsd commented 1 year ago

@P4sca1 Thank you for the response, It's happened in VIte Svetekit the error is

[plugin:vite:import-analysis] Missing "./schedulers/interval-based" specifier in "cron-schedule" package

I tried to import

cron-schedule/schedulers/timer-based.js

and

cron-schedule/dist/schedulers/timer-based.js

both ways doesn't work

vite.config.js

import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';

export default defineConfig({
    plugins: [sveltekit()],
    css: { postcss: './config/postcss.config.cjs' }
});

svelte.config.js

import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/kit/vite';

const config = {
    preprocess: vitePreprocess(),

    kit: {
        adapter: adapter(),
        paths: {},
        prerender: {}
    }
};

export default config;

tsconfig.json

{
    "extends": "./.svelte-kit/tsconfig.json",
    "compilerOptions": {
        "allowJs": true,
        "checkJs": true,
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "resolveJsonModule": true,
        "skipLibCheck": true,
        "sourceMap": true,
        "strict": true
    }
    // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
    //
    // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
    // from the referenced tsconfig.json - TypeScript does not merge them in
}

It was for this project https://github.com/ntsd/auto-evm-wallet I published the new version that works.

P4sca1 commented 1 year ago

If you’re using Node 12 or 14, you should use --moduleResolution node16. The features added to 16 have fully or mostly been backported to 12 and 14. --moduleResolution node is for Node 11 and older. Its name is currently bad. We plan to rename it accordingly.

https://github.com/microsoft/TypeScript/issues/50794

The package exports work as expected with the correct module resolution. The minimum required node version is node 16 to use this package. If you need to use another version, please see version 3 of this package.

ntsd commented 1 year ago

If you’re using Node 12 or 14, you should use --moduleResolution node16. The features added to 16 have fully or mostly been backported to 12 and 14. --moduleResolution node is for Node 11 and older. Its name is currently bad. We plan to rename it accordingly.

microsoft/TypeScript#50794

The package exports work as expected with the correct module resolution. The minimum required node version is node 16 to use this package. If you need to use another version, please see version 3 of this package.

Got it, Thank you for explaining.