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
events.js:72
throw er; // Unhandled 'error' event
^
Error: tried to statically call { readFile: [Function: readFile], readFileSync: [Function: readFileSync], readdir: [Function: readdir], readdirSync: [Function: readdirSync] } as a function while parsing file: /Users/akula/foo/main.js while parsing file: /Users/akula/foo/main.js
at error (/Users/akula/foo/node_modules/brfs/node_modules/static-module/index.js:71:49)
at traverse (/Users/akula/foo/node_modules/brfs/node_modules/static-module/index.js:247:24)
at walk (/Users/akula/foo/node_modules/brfs/node_modules/static-module/index.js:216:13)
at walk (/Users/akula/foo/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:60:9)
at /Users/akula/foo/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:51:25
at Array.forEach (native)
at forEach (/Users/akula/foo/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:8:31)
at /Users/akula/foo/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:49:17
at Array.forEach (native)
at forEach (/Users/akula/foo/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:8:31)
btw, there's a double "while parsing file" in the message.
My main.js looks like this.
import fs from 'fs';
var foo = fs.readFileSync(__dirname + '/foo.html');
console.log(foo.toString());
If I change the import to a require and don't do 6to5ify it works fine, but together it gives the error.
I'm using brfs 1.4.1 which pulls in static-module 1.1.3 and still can't get brfs to work happily with ES6/babelify. Using same workaround as others for the moment, var fs = require('fs').
@jedrichards after some time using import for importing CommonJS modules I realized it’s really a kind of hack. fs is a CommonJS module and const fs = require('fs') seems the right thing to do to me.
import is intended for real modules which use export for exporting things. And fs is not one of these yet.
Tou say "import is intended for real modules which use export for exporting things. And fs is not one of these yet."
Over the last few days, I have created and imported modules that use both the module.exports and the plain export idiom. I have working modules that import one of each.
Mixed_Imports.zip contains GridProperties.js, which imports both CommonConstants.js, which uses the plain export idiom, and PropertyDisplayHelpers.js, which uses the module.exports idiom.
Activity
erykpiast commentedon Feb 5, 2015
Ack! The same problem with 6to5@3.1.2 and brfs@1.3.0 on Node@0.10.25 for Linux.
erykpiast commentedon Feb 5, 2015
But it works perfectly fine when used like
I don't have to disable 6to5.
vegetableman commentedon Feb 28, 2015
Faced this problem as well.
danharper commentedon Mar 5, 2015
I'm guessing this is down to how Babel (was: 6to5) transpiles ES6 imports. This:
Becomes this:
If you want to go this route, resorting to a regular
requirecall works fine:nicroto commentedon Mar 18, 2015
Just hit that, too.
lambdabaa commentedon Apr 8, 2015
agh
v1.6.4 - Workaround for browserify/brfs#39
dustinmoorenet commentedon Apr 8, 2015
👍
revolunet commentedon May 28, 2015
looks like static-module has been updated with ES6 support ? browserify/static-module@2eb7ce0
jedrichards commentedon Sep 16, 2015
I'm using brfs 1.4.1 which pulls in static-module 1.1.3 and still can't get brfs to work happily with ES6/babelify. Using same workaround as others for the moment,
var fs = require('fs').tomek-he-him commentedon Sep 16, 2015
@jedrichards after some time using
importfor importing CommonJS modules I realized it’s really a kind of hack.fsis a CommonJS module andconst fs = require('fs')seems the right thing to do to me.importis intended for real modules which useexportfor exporting things. Andfsis not one of these yet.Fix browserify/brfs#39
txwizard commentedon Apr 24, 2018
Tou say "import is intended for real modules which use export for exporting things. And fs is not one of these yet."
Over the last few days, I have created and imported modules that use both the
module.exportsand the plainexportidiom. I have working modules that import one of each.Mixed_Imports.zip contains
GridProperties.js, which imports bothCommonConstants.js, which uses the plainexportidiom, andPropertyDisplayHelpers.js, which uses themodule.exportsidiom.