remotestorage/remotestorage.js

Export assignment cannot be used when targeting ECMAScript modules. in 2.0.0 beta.

Closed this issue · 2 comments

Version: 2.0.0-beta.6

When importing import RemoteStorage from "remotestoragejs" in a Svelte app I get many errors from typescript in the form of:

/home/kevincox/p/recipes/node_modules/remotestoragejs/src/wireclient.ts:431:1
Error: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. 

export = WireClient;


/home/kevincox/p/recipes/node_modules/remotestoragejs/src/sync.ts:1107:1
Error: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. 

export = Sync;


/home/kevincox/p/recipes/node_modules/remotestoragejs/src/features.ts:257:1
Error: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. 

export = Features;


/home/kevincox/p/recipes/node_modules/remotestoragejs/src/remotestorage.ts:971:1
Error: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. 

export = RemoteStorage;

I must admit that I have not seen this syntax before but it seems that what is being done could be accomplished with export default RemoteStorage and similar.

Ah, I found the docs here: https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require

It appears to be some compatibility for AMD and CommonJS modules. However it doesn't seem to work at all for ECMAScript modules.

Oddly enough reloading my long-running typescript compiler fixed the issue. So I guess the current code is fine and just a bad state in the compiler? Strange.