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

Regression @rollup/plugin-commonjs v13.0.0 #454

Closed
MatthiasKainer opened this issue Jun 14, 2020 · 3 comments · Fixed by #501
Closed

Regression @rollup/plugin-commonjs v13.0.0 #454

MatthiasKainer opened this issue Jun 14, 2020 · 3 comments · Fixed by #501

Comments

@MatthiasKainer
Copy link

  • Rollup Plugin Name: @rollup/plugin-commonjs
  • Rollup Plugin Version: v13.0.0
  • Rollup Version: 1.32.1
  • Operating System (or Browser): any
  • Node Version: any

How Do We Reproduce?

https://repl.it/repls/PhonyUsefulNanotechnology#output/bundle.js

Have a file like

import {LitElement, html} from "lit-element"
import { useState } from "lit-element-state-decoupler";
import {useOnce} from "lit-element-effect";

export class Element extends LitElement {
  render() {
    const {getState, publish} = useState(this, false)
    useOnce(this, () => publish(true))

    return html`<div>Called: ${getState()}<div>`
  }
}

Expected Behavior

The imports are resolved correctly. In the bundle that would create a result:

class Element extends LitElement {
  render() {
    const {getState, publish} = index.useState(this, false);
    index$1.useOnce(this, () => publish(true));

    return html`<div>Called: ${getState()}<div>`
  }
}

(Note the index$1 on useOnce)

Actual Behavior

useOnce is retrieved from index, which obviously fails:

class Element extends LitElement {
  render() {
    const {getState, publish} = index.useState(this, false);
    index.useOnce(this, () => publish(true));

    return html`<div>Called: ${getState()}<div>`
  }
}

Workaround

Use version 12.0.0 of @rollup/plugin-commonjs instead of v13.0.0

MatthiasKainer added a commit to MatthiasKainer/lit-element-effect that referenced this issue Jun 14, 2020
@vladshcherbin
Copy link

I've got same thing with another library, also with index near this line:

console.log(1, lib)

var index = /*@__PURE__*/unwrapExports(lib);

console.log(2, index)

I believe exports are unwrapped incorrectly, here is result:

image

From source code function checks for default export and uses it, however object can have other keys which will be removed.

Bundling results in an application error shown above. Workaround is to use 12.0.0.

Will be probably fixed with #465

@lukastaegert
Copy link
Member

I started #481 to move all interop issues including this one forward.

@lukastaegert
Copy link
Member

I can confirm that #501 solves this issue.

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