cs50 / publish50-electron

9 stars 2 forks source link

change the modules in src/ to use es6 module syntax #48

Open kzidane opened 4 years ago

kzidane commented 4 years ago

Instead of using CommonJS syntax (e.g., in src/logger.js and src/job_helper.js) and importing the module with require, let's try using ES6 module syntax and import using import just to be consistent with other modules under src/.

https://exploringjs.com/es6/ch_modules.html#_multiple-named-exports

rongxin-liu commented 4 years ago

Hey, what does src/logger.js do exactly? I can see that it is used in CDNPath.js (logger.error()), but maybe we don't have a function named "error" defined in src/logger.js ?

kzidane commented 4 years ago

It exports electron-log so we can log stuff from the frontend: https://github.com/cs50/publish50-electron/blob/develop/public/preload.js#L3 https://github.com/cs50/publish50-electron/blob/develop/src/logger.js#L1 https://github.com/cs50/publish50-electron/blob/develop/src/logger.js#L1 https://www.npmjs.com/package/electron-log#usage