Open brandonmack111 opened 6 years ago
I have the same problem with the unwrap
import.
import { unwrap } from '@sweet-js/helpers' for syntax ;
syntax x2 = function(ctx){
let nextToken = ctx.next().value ;
return #`${unwrap(nextToken).value} ${unwrap(nextToken).value}`
}
x2 [1, 2, 3] ;
The output is:
skipping module @sweet-js/helpers:1
evalmachine.<anonymous>:5
return syntaxTemplate(1, unwrap(nextToken_2).value, unwrap(nextToken_2).value);
^
ReferenceError: unwrap is not defined
at evalmachine.<anonymous>:5:5
at Enforester.expandMacro (A:\App files\Node.js v8.12.0\node_modules\@sweet-js\cli\node_modules\@sweet-js\core\dist\enforester.js:1981:87)
at Enforester.enforestStatement (A:\App files\Node.js v8.12.0\node_modules\@sweet-js\cli\node_modules\@sweet-js\core\dist\enforester.js:349:12)
at Enforester.enforestModuleItem (A:\App files\Node.js v8.12.0\node_modules\@sweet-js\cli\node_modules\@sweet-js\core\dist\enforester.js:136:17)
at Enforester.enforestBody (A:\App files\Node.js v8.12.0\node_modules\@sweet-js\cli\node_modules\@sweet-js\core\dist\enforester.js:123:17)
at Enforester.enforestModule (A:\App files\Node.js v8.12.0\node_modules\@sweet-js\cli\node_modules\@sweet-js\core\dist\enforester.js:119:17)
at Enforester.enforest (A:\App files\Node.js v8.12.0\node_modules\@sweet-js\cli\node_modules\@sweet-js\core\dist\enforester.js:109:21)
at TokenExpander.expand (A:\App files\Node.js v8.12.0\node_modules\@sweet-js\cli\node_modules\@sweet-js\core\dist\token-expander.js:133:37)
at Compiler.compile (A:\App files\Node.js v8.12.0\node_modules\@sweet-js\cli\node_modules\@sweet-js\core\dist\compiler.js:50:26)
at NodeLoader.compileSource (A:\App files\Node.js v8.12.0\node_modules\@sweet-js\cli\node_modules\@sweet-js\core\dist\sweet-loader.js:211:53)
By the way, that example I've just posted doesn't work in the online editor either.
It's still a problem.
File: foo.js
'lang sweet.js'
import { unwrap } from '@sweet-js/helpers' for syntax;
export syntax foo = (ctx) => {
console.log(`unwrap = ${typeof(unwrap)}`);
return #`let x;`;
File index.js
import { foo } from './foo.js';
foo;
console -> unwrap = undefined
Did they find a solution to this? I'm having the exact same problem :/
The fix is to install the sweet helpers package inside your project
npm install @sweet-js/helpers
Installing the helpers locally rather than globally does seem to do the trick.
I can use sweet.js fine for most use cases, but any time I try to use imports from standard libraries, it fails to work. Here's an example from the documentation:
the error I get when I try to complie: