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

bundleNodeModules results in Error: 'default' is not exported #260

Open
johannes-z opened this issue Nov 12, 2019 · 7 comments
Open

bundleNodeModules results in Error: 'default' is not exported #260

johannes-z opened this issue Nov 12, 2019 · 7 comments
Labels

Comments

@johannes-z
Copy link

Stack Trace:
Error: 'default' is not exported by ..\..\..\..\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js

I'm trying to create bundles with esm and umd, but the build fails because apparently the library I'm using doesn't export default. Apparently the library dist file is an umd file:

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.VueInfiniteLoading=e():t.VueInfiniteLoading=e()}
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.84. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the bug label Nov 12, 2019
@hosein2398
Copy link
Contributor

Can you provide more information,
I just tested everything with vue-infinite-loading and it works fine.
I was able to get umd and esm bundle output.
What's the command you are running? or your config file

@johannes-z
Copy link
Author

@hosein2398 Sorry yes you are right, I tried a minimal repro, and there it worked. There must be something wrong with the monorepo setup I got at work. I'll try to repro it again before I close this issue though

@johannes-z
Copy link
Author

@hosein2398 I'm pretty sure it's because of the yarn-monorepo setup I have. It doesn't seem to resolve the symlinks correctly. See the path: ..\..\..\..\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js.

@johannes-z
Copy link
Author

Please check out this repo: https://github.com/johannes-z/bili-yarn-monorepo
You need yarn, just run yarn in the root and npx bili in the flexgrid package folder. It should fail with the above error message.

@johannes-z
Copy link
Author

johannes-z commented Nov 15, 2019

I added this to bili.config.ts, which seems to resolve this issue. I'm not sure if this is correct however.

  extendRollupConfig: config => {
    config.inputConfig.preserveSymlinks = true
    return config
  },

Actually this only worked, because I was building an esm bundle. Building umd still fails with the same error.

@johannes-z
Copy link
Author

johannes-z commented Nov 15, 2019

Adding exclude to the babel plugin seems to work, but this obviously seems like a dirty hack.

    babel: {
      exclude: /node_modules\/(?:vue-infinite-loading)/gi,
    },

Also, is this setting merged with the default exclude option?

exclude: ['transform-regenerator', 'transform-async-to-generator']

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

No branches or pull requests

2 participants