sweet-js / sweet-core

Sweeten your JavaScript.
https://www.sweetjs.org
BSD 2-Clause "Simplified" License
4.58k stars 208 forks source link

Sweet Module example is not working #693

Open manisuec opened 7 years ago

manisuec commented 7 years ago

http://www.sweetjs.org/doc/1.0/tutorial.html#_sweet_modules

I tried the example given at the above link and it is giving me below error

/usr/lib/node_modules/@sweet-js/cli/node_modules/resolve/lib/sync.js:42 throw err; ^

Error: Cannot find module './es2015-macros'

Updated the path in import statement to 'import { class } from './es2015-macros.js'; ' i.e. added .js in the module name. Re-run the example but getting below error this time

/usr/lib/node_modules/@sweet-js/cli/node_modules/sweet-core/dist/syntax.js:360 throw new Error('Scopeset ' + debugBase + ' has ambiguous subsets ' + debugAmbigousScopesets); ^

Error: Scopeset {outsideEdge_5} has ambiguous subsets {outsideEdge_5}, {outsideEdge_5} at Syntax.resolve (/usr/lib/node_modules/@sweet-js/cli/node_modules/sweet-core/dist/syntax.js:360:17)

NSilv commented 7 years ago

I worked a bit with the example above. Found out that the macro works if used in the same file, and the error gets thrown when the macro gets imported. Dunno what's causing it though.

manisuec commented 7 years ago

Same here....

gabejohnson commented 7 years ago

I can't reproduce this, but I also can't get the class macro to expand. @manisuec can we get a look at your code please?

disnet commented 7 years ago

I can repro it. The extension problem must have been recently introduced. I'll fix and add regression tests for that.

The ambiguous scopesets error is surprising because I thought we had tests for that. I'll investigate.

gabejohnson commented 7 years ago

@disnet any idea why this cropped up after the project was split?

disnet commented 7 years ago

I think the extension issue was introduced in https://github.com/sweet-js/sweet-core/commit/1087af322cb7589953e69dc40e2b636a059a89f5#diff-828804bf7ffcce021806a0fc90ea20f9

Defaulting to the empty array was the problem.

The scopeset issue has been there since introducing recursive modules I think. I'll write up what happened when I get a fix ready (should be soon).