remotestorage / remotestorage.js

⬡ JavaScript client library for integrating remoteStorage in apps
https://remotestoragejs.readthedocs.io
MIT License
2.3k stars 141 forks source link

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

Closed kevincox closed 1 year ago

kevincox commented 1 year ago

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.

kevincox commented 1 year ago

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.

kevincox commented 1 year ago

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.