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

Issue with packages that do no export a default #71

Open
leibowitz opened this issue Jan 24, 2020 · 1 comment
Open

Issue with packages that do no export a default #71

leibowitz opened this issue Jan 24, 2020 · 1 comment

Comments

@leibowitz
Copy link
Contributor

I'm having an issue processing a certain package with this plugin, namely stream-chat

It seems they do not have a default export, which means it requires to be imported in this way:

import { StreamChat } from 'stream-chat';

And I don't know how to translate that to webpack-cdn-plugin. I don't seem to get it to work. According to the doc, var need to be specified – otherwise stream-chat breaks as it's not a valid variable name.

external_"stream-chat":1 Uncaught ReferenceError: stream is not defined

From this code:

/*!******************************!*\
  !*** external "stream-chat" ***!
  \******************************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = stream-chat;\n\n//# sourceURL=webpack:///external_%22stream-chat%22?");

I tried setting it with 'var': 'StreamChat', which seems to pass the previous error, but then it fails with another error:

stream_chat__WEBPACK_IMPORTED_MODULE_1__.StreamChat is not a constructor

When it tries to replace StreamChat in the code with:

stream_chat__WEBPACK_IMPORTED_MODULE_1__["StreamChat"]

I believe the issue is because the package do not export itself properly, and I would like to report the issue with the project, but I don't know how to phrase it. Any help to understand what's needed would be appreciated

@shirotech
Copy link
Owner

Hi @leibowitz

Thanks for reporting, I might have two available options you can try to see if it works.

  1. Find a way to import the cjs version of the package instead of the es version, with the cjs the default is always available, it will be a single object with all the exported module.
  2. Create a bridge repo and publish to npm e.g. export {StreamChat as default} from 'stream-chat'

Other than that, I'm not sure any way around it as I haven't touched the codebase for a while and might be missing something.

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

2 participants