[Plugin Dev] Object spread operator not working: cannot find module 'core-js/modules/web.dom.iterable'

Bug report

I’m trying to build a simple plugin in which I do something very similar to this from inkdrop-export-as-html. However I notice including the spread operator ({...myObj}) is causing Inkdrop to error on load with Cannot find module core-js/modules/web.dom.iterable.

I’m running in dev mode and have my plugin symlinked to the user data directory as recommended. Is there something I need to do to allow this functionality? Obviously I don’t have to use the spread operator, but it is very convenient. I assume the official plugin is being compiled in a different environment and that’s why it can use it but my plugin cannot?

Reproduction:

# my_plugin/index.js

module.exports = {
  activate() {
    const obj = {}
    const spread = {...obj}
  },
  deactivate() { }
}

Thanks for any info!

Info

  • Platform: macOS
  • Platform version: Mojave
  • App Version: 4.5.2

I’ve had the same problem in the past, add core-js@2.x as dependency to your project to fix the issue.

1 Like

Thank you, that makes sense!

1 Like

Found it’s a bug that the app’s internal babel config is incorrect that it tries to use core-js@2 but it has 3.
Will be fixed it in the next release.
Please use the Jasper’s workaround for now.
Thanks for the report!

1 Like

Fixed in v4.6.0 :tada:

  • Now it uses core-js@3 properly, so you don’t need to add core-js@2 as your plugin dependency
  • The recent Electron does support the most of ES6 features like Object Spread without using Babel