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
I'm using "babel-preset-es2015": "^6.9.0" with "babelify": "^7.3.0", and import sf from 'sheetify'; doesn't work (5.0.3 of sheetify). I get:
Uncaught TypeError: (0 , _sheetify2.default) is not a function
1.on-load @ google-map.js:4
s @ _prelude.js:1
(anonymous function) @ _prelude.js:12
../components/google-map @ index.js:3
s @ _prelude.js:1
e @ _prelude.js:1
(anonymous function) @ _prelude.js:1
idk man; import is barely useful as a spec, and I've got no idea what Babel's specific implementation quirks are - maybe someone else knows what's up; if you stumble upon a solution I reckon posting it back here would be greatly appreciated. Cheers!
sheetify/transform only supports require, and i think babelify transpiles import into a non-statically-analyzable require (by wrapping it in a dynamic function) so that doesn't help.
so possible options:
change import sf from 'sheetify' to const sf = require('sheetify')
add support for ES Modules to sheetify/transform, so you could add it before babelify and it'd work.
i personally don't care for ES Modules, but if anyone wants to contribute here i'm keen.
I'd strongly urge people to steer clear from import as it's less flexible, poorly defined (loader, anyone) and in its current form might not even make it to Node 😞 - way too much overhead for only syntax imo
change import sf from 'sheetify' to const sf = require('sheetify')
Might be the simple solution, however acorn wont like files mixing import and require. ('import' and 'export' may appear only with 'sourceType: module'). To allow that, transform.js could be patched to use allowImportExportEverywhere: true option on the falafel calls.
Activity
yoshuawuyts commentedon Jun 29, 2016
idk man;
importis barely useful as a spec, and I've got no idea what Babel's specific implementation quirks are - maybe someone else knows what's up; if you stumble upon a solution I reckon posting it back here would be greatly appreciated. Cheers!ahdinosaur commentedon Jul 1, 2016
hey @knownasilya,
sheetify/transformonly supportsrequire, and i thinkbabelifytranspilesimportinto a non-statically-analyzablerequire(by wrapping it in a dynamic function) so that doesn't help.so possible options:
import sf from 'sheetify'toconst sf = require('sheetify')sheetify/transform, so you could add it beforebabelifyand it'd work.i personally don't care for ES Modules, but if anyone wants to contribute here i'm keen.
tj commentedon Jul 16, 2016
import { default as css } from 'sheetify'works fine for me, though definitely not as nice! kinda wonky to support both thoughyoshuawuyts commentedon Jul 16, 2016
I'd strongly urge people to steer clear from
importas it's less flexible, poorly defined (loader, anyone) and in its current form might not even make it to Node 😞 - way too much overhead for only syntax imotj commentedon Jul 16, 2016
agreed, the syntax they came up with is pretty ridiculous but oh well haha
knownasilya commentedon Jul 16, 2016
@tj thanks for the tip
mciparelli commentedon Aug 10, 2016
@tj approach didn't work for me :(
fczuardi commentedon Sep 19, 2016
Based on the outputs of rollup and babel for this file:
Outputs before transform:
(rollup)
(babel-cli)
One possible patch for the transform.js could be something like:
transform.js
fczuardi commentedon Sep 19, 2016
if this should be implemented at all, or live under an option, or be a different project altogether is open for discussion ;)
fczuardi commentedon Sep 19, 2016
the first solution proposed by @ahdinosaur
Might be the simple solution, however acorn wont like files mixing import and require. (
'import' and 'export' may appear only with 'sourceType: module'). To allow that, transform.js could be patched to useallowImportExportEverywhere: trueoption on the falafel calls.ngryman commentedon Jan 6, 2017
@yoshuawuyts What do you think about the last proposed solution of @fczuardi? I think it's a good compromise for only a small change.
chinedufn commentedon Apr 28, 2018
If you maintain something that uses ES Modules you can just fork
sheetifyand do something like thishttps://github.com/chinedufn/sheetify/blob/master/transform.js#L82-L91
Then depend on your fork.
Assuming you have no other reasonable option and you're cool with all that comes with depending on a own fork instead of mainline.
sourceType: 'module'is the important bit