-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
Improper ES6 import statement breaks (so far unnoticed because of correct CJS result) #892
Comments
Currenlty a workaround for the problem is to force loading the cjs version: |
Bump. Hello guys, this is actually an easy fix, and a pretty basic bug... Can someone please take a look? Here is an online repro: https://codesandbox.io/s/cycletime-improper-import-statement-kgd02 I don't know about the CI builds and tests (I tried, but they were not up-to-date, I see there's some work on it nowadays), but I know that the fix doesn't change the cjs result, so no tests should be impacted. |
Code to reproduce the issue:
index.js:
index.html:
package.json:
Open http://localhost:1234/ in the browser.
Expected behavior:
Nothing happens, empty screen, no log message.
Actual behavior:
JS error thrown:
Uncaught TypeError: requestAnimationFrame is not a function
Versions of packages used:
See above in package.json
I provided a fix at #891
The problem is this 2 lines in
@cycle/time/lib/es6/src/time-driver.js
:Those 2 modules export functions, not namespace objects.
import *
always creates a plain namespace object, which can't be invoked. The correct import statement is without the wildcard:This bug was unnoticed so far, because most bundler setups are pulling the cjs version (
@cycle/time/lib/cjs/src/time-driver.js
) instead of the es6 one, and both types of import statements produces the samevar <f> = require('...')
statement in cjs, which works, because it pulls in the module.exports object - in these cases the function itself.The es6 version is broken however, and with bundlers which use the es6 version, the result bundle will break.
The text was updated successfully, but these errors were encountered: