Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Fail to import deconstructed object variable with Literals declaration #303

Closed
edoardocavazza opened this issue Mar 14, 2018 · 3 comments · Fixed by #383
Closed

Fail to import deconstructed object variable with Literals declaration #303

edoardocavazza opened this issue Mar 14, 2018 · 3 comments · Fixed by #383

Comments

@edoardocavazza
Copy link

edoardocavazza commented Mar 14, 2018

The plugin fails bundling a module which exports a variable from deconstruction with literal keys.

[!] (commonjs plugin) TypeError: extractors[prop.key.type] is not a function

Example
module.js

const obj = {
    index: 0,
    1: 1,
    2: 2,
    3: 3,
};

let {
    index: a,
    1: b,
    2: c,
    3: d
} = obj;

module.exports = b;

index.js

import b from './module.js';

It seems a rollup-pluginutils failure (here the related issue and PR). Also, the extractNames helper in rollup-plugin-commonjs could have the same issue.

@edoardocavazza edoardocavazza changed the title Fail to import ObjectPattern declaration with Literals Fail to import deconstructed object variable with Literals declaration Mar 14, 2018
@ispyinternet
Copy link

Looks like I'm hitting this when trying to rollup sequelize, the code in particular:

 static _defaultsOptions(...args) {
         return this._baseMerge(...args, (...cbArgs) => {
          [cbArgs[0], cbArgs[1]] = [cbArgs[1], cbArgs[0]];
          return this._mergeFunction(...cbArgs);
        });
  }

https://github.com/sequelize/sequelize/blob/4ec86a4bd43aa65e45546e2d4177ffcbeb2b4bac/lib/model.js#L817

@lukastaegert
Copy link
Member

This particular issue should be fixed in the latest release via #358

@ispyinternet
Copy link

I don' think it is because the call to

MemberExpression(names, node) {
		extractors[node.property.type](names, node.property);
	}

is made where node.property.type = 'Literal' and this method doesn't exist on the extractors object.

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

Successfully merging a pull request may close this issue.

3 participants