Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load from an ES module #158

Open
crystalfp opened this issue Oct 29, 2021 · 1 comment
Open

Unable to load from an ES module #158

crystalfp opened this issue Oct 29, 2021 · 1 comment

Comments

@crystalfp
Copy link

I'm in the process of modernizing my application moving it from AMD to ES modules. With the classic KO that was not possible and someone suggested to move to TKO, so I installed 4.0.0-alpha9.0.

I'm using the importmap (https://wicg.github.io/import-maps/) that is implemented in Chrome to map from "knockout" to the
"../node_modules/@tko/build.reference/dist/build.reference.es6.js" library.

Loading TKO this way: import ko from "knockout"; now gives a runtime error:
Uncaught SyntaxError: The requested module 'knockout' does not provide an export named 'default'

Loading that way: import * as ko from "knockout"; gives a different runtime error:

build.reference.es6.js:10 Uncaught TypeError: Cannot set properties of
undefined (setting 'ko')
    at build.reference.es6.js:10
    at build.reference.es6.js:11

Tried also with the other library build.reference.js: with identical results. BTW, is build.reference.es6.js the library that supports ES modules?

The modules are compiled from Typescript, but don't think this is relevant here.

Thanks for your help. I'm quite desperate.

@crystalfp
Copy link
Author

The real problem is that both typeof exports and typeof module are undefined, so I cannot import the library this way as expected: import tko from "..../build.reference.es6.js"

Any idea how to import tko in an ES Module?
Thanks!
mario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant