You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should print the current date to console, no errors. Eg:
2024-05-19T03:47:19.008Z
What do you see instead?
Bun reports error because exports.now is undefined:
40 | if (typeof format !== "string") {
41 | date = format;
42 | format = exports.ISO8601_FORMAT;
43 | }
44 | if (!date) {
45 | date = exports.now();
^
TypeError: exports.now is not a function. (In 'exports.now()', 'exports.now' is undefined)
at asString (/home/geoff/tmp/expr/testcase/build/index.js:45:14)
at /home/geoff/tmp/expr/testcase/build/index.js:184:13
Bun v1.1.8 (Linux x64)
If we look in the source codes of date-format package, we see module.exports.now() - bun removed the module. qualification which breaks the library:
// from node_modules/date-format/lib/index.jsfunctionasString(format,date){if(typeofformat!=="string"){date=format;format=module.exports.ISO8601_FORMAT;}if(!date){date=module.exports.now();}
If I edit build/index.js and change back to module.exports.now the codes works as expected.
Additional information
I originally found this because log4js was erroring when using bun build and bun build --compile:
914 | }
915 | var vDay = addZero(date.getDate());
916 | var vMonth = addZero(date.getMonth() + 1);
917 | var vYearLong = addZero(date.getFullYear());
918 | var vYearShort = addZero(vYearLong.substring(2, 4));
919 | var vYear = format.indexOf("yyyy") > -1 ? vYearLong : vYearShort;
^
TypeError: undefined is not an object (evaluating 'format.indexOf')
at asString (/home/geoff/tmp/expr/testcase/build/index.js:919:17)
at timestampLevelAndCategory (/home/geoff/tmp/expr/testcase/build/index.js:1062:52)
at colouredLayout (/home/geoff/tmp/expr/testcase/build/index.js:1068:12)
at /home/geoff/tmp/expr/testcase/build/index.js:1813:31
at /home/geoff/tmp/expr/testcase/build/index.js:6044:7
at forEach (:1:21)
at sendLogEventToAppender (/home/geoff/tmp/expr/testcase/build/index.js:6043:5)
at forEach (:1:21)
at sendToListeners (/home/geoff/tmp/expr/testcase/build/index.js:1680:5)
at send (/home/geoff/tmp/expr/testcase/build/index.js:1731:9)
Bun v1.1.8 (Linux x64)
What version of Bun is running?
1.1.8+89d25807f
What platform is your computer?
Linux 6.1.0-17-amd64 x86_64 unknown
What steps can reproduce the bug?
When using
bun build
with date-format,modules.exports
is getting transpiled toexports
which causes runtime errors.This testcase demonstrates the error - I was also getting a similar error from log4js
create project
index.ts
build
run testcase
What is the expected behavior?
Should print the current date to console, no errors. Eg:
What do you see instead?
Bun reports error because
exports.now
is undefined:If we look in the source codes of
date-format
package, we seemodule.exports.now()
- bun removed themodule.
qualification which breaks the library:If I edit
build/index.js
and change back tomodule.exports.now
the codes works as expected.Additional information
I originally found this because log4js was erroring when using
bun build
andbun build --compile
:Workaround
--external=date-format
node_modules/date-format
resolvableFound via: #7024
The text was updated successfully, but these errors were encountered: