sojinantony01 / react-cron-generator

Simple react component to generate cron expressions
MIT License
78 stars 62 forks source link

SyntaxError: Unexpected token #49

Closed garg-mahendra closed 1 year ago

garg-mahendra commented 1 year ago

In the latest version I'm getting this error.

SyntaxError:/node_modules/react-cron-generator/build/index.js: Unexpected token (7490:8)
  7488 |                 throw new Error('translateFn expects a string translation');
  7489 |             }
> 7490 |         }
       |         ^
  7491 |         return translatedText;
  7492 |     };
  7493 |     return (jsxRuntime.jsxs("div", Object.assign({ className: 'cron_builder' }, { children: [jsxRuntime.jsx("ul", Object.assign({ className: "nav nav-tabs" }, { children: getHeaders() })), jsxRuntime.jsx("div", Object.assign({ className: "cron_builder_bordering" }, { children: state.selectedTab ? getComponent(state.selectedTab) : "Select a header" })), props.showResultText && jsxRuntime.jsx("div", Object.assign({ className: "cron-builder-bg" }, { children: getVal() })), props.showResultCron && jsxRuntime.jsx("div", Object.assign({ className: "cron-builder-bg" }, { children: state.value.toString().replace(/,/g, ' ').replace(/!/g, ',') }))] })));
WARNING in ./node_modules/react-cron-generator/build/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'index.js.map': SyntaxError: Unexpected token C in JSON at position 504225

ERROR in ./node_modules/react-cron-generator/build/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError:/node_modules/react-cron-generator/build/index.js: Unexpected token (7490:8)

  7488 |                 throw new Error('translateFn expects a string translation');
  7489 |             }
> 7490 |         }
       |         ^
  7491 |         return translatedText;
  7492 |     };
  7493 |     return (jsxRuntime.jsxs("div", Object.assign({ className: 'cron_builder' }, { children: [jsxRuntime.jsx("ul", Object.assign({ className: "nav nav-tabs" }, { children: getHeaders() })), jsxRuntime.jsx("div", Object.assign({ className: "cron_builder_bordering" }, { children: state.selectedTab ? getComponent(state.selectedTab) : "Select a header" })), props.showResultText && jsxRuntime.jsx("div", Object.assign({ className: "cron-builder-bg" }, { children: getVal() })), props.showResultCron && jsxRuntime.jsx("div", Object.assign({ className: "cron-builder-bg" }, { children: state.value.toString().replace(/,/g, ' ').replace(/!/g, ',') }))] })));
    at instantiate (node_modules/@babel/parser/lib/index.js:72:32)
    at constructor (node_modules/@babel/parser/lib/index.js:358:12)
    at Parser.raise (node_modules/@babel/parser/lib/index.js:3336:19)
    at Parser.unexpected (node_modules/@babel/parser/lib/index.js:3374:16)
    at Parser.parseExprAtom (node_modules/@babel/parser/lib/index.js:13120:22)
    at Parser.parseExprSubscripts (node_modules/@babel/parser/lib/index.js:12645:23)
    at Parser.parseUpdate (node_modules/@babel/parser/lib/index.js:12624:21)
    at Parser.parseMaybeUnary (node_modules/@babel/parser/lib/index.js:12595:23)
    at Parser.parseMaybeUnaryOrPrivate (node_modules/@babel/parser/lib/index.js:12389:61)
    at Parser.parseExprOps (node_modules/@babel/parser/lib/index.js:12396:23)
SojinAntony commented 1 year ago

Please share more details, React version Node JS version
OS and cron gen version as well ...

garg-mahendra commented 1 year ago

Please share more details, React version Node JS version OS and cron gen version as well ...

"react": "^18.1.0", node: v16.15.1 OS: WSL2 Ubuntu Description: Ubuntu 20.04.4 LTS react-cron-generator": "2.0.3"

sojinantony01 commented 1 year ago

@garg-mahendra

Fixed the issue, updated rollup config and versions

Please use latest cron generator version. 2.0.8 if already installed please uninstall and install package again.

Thanks for reporting the issue.

Feel free to reopen if you same issue again

garg-mahendra commented 1 year ago

Thanks for the quick resolution of the mentioned bug.

@sojinantony01 @SojinAntony one thing I want to understand why the values of generated by the react-cron-generator showing invalid cron expression when I'm validating these expression in backend, for instance

Python Code, even I tried some online tools those also says these are invalid cron. like https://crontab.guru/

from cron_validator import CronScheduler, CronValidator
cron_string="0 10 11 1/1 * ? *"
CronScheduler(cron_string)

// *** ValueError: Invalid expression // error
sojinantony01 commented 1 year ago

Is it happening for all cron expressions creating from react cron generator? or only this one?

if yestry deleting last value from cron expressions (year value) convert it to a 6 value cron expression and use it

garg-mahendra commented 1 year ago

Thanks for quick response, Yes, In all expression facing same issue. Do you mean from cron_string="0 10 11 1/1 ? " At 11:10:00 am, every day starting on the 1st, every month to cron_string="0 10 11 1/1 * ? " still not valid

but this will change the value of cron,

sojinantony01 commented 1 year ago

Ok let me try same here

garg-mahendra commented 1 year ago

Ok let me try same here

okay, I've not find solution yet.