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

multi-var statement gets mangled [regression in 0.22.1] #390

Closed
lukeapage opened this issue Dec 30, 2015 · 5 comments
Closed

multi-var statement gets mangled [regression in 0.22.1] #390

lukeapage opened this issue Dec 30, 2015 · 5 comments

Comments

@lukeapage
Copy link
Contributor

Unfortunately the code is closed source so I'll try and paint a picture of what is going on..

I'm using format iife and the rollup-plugin-babel all latest versions.

I have code like..

import mockFetch from '../../mocks/fetch';

var a, fetch;

describe("x", () => {
    beforeEach(() => {
        fetch = mockFetch();
        installClock();
    });

fetch is a global and is used as a global in mockFetch, so I guess rollup needs to rename the var fetch

but it becomes

    var a;
    fetch$1;
    describe("x", function () {
        beforeEach(function () {
            fetch$1 = mockFetch();
            installClock();
        });

which means that fetch$1 isn't defined and the code falls over.

This was working a couple of weeks ago so I'll try and figure out what version causes the issue.

@lukeapage
Copy link
Contributor Author

ok thats simple, this occurs in 0.22.1 but not 0.22.0.

In 0.22.0 I get the following output

var a;
var fetch$1;

@lukeapage lukeapage changed the title multi-var statement gets mangled [regression] multi-var statement gets mangled [regression in 0.22.1] Dec 30, 2015
@kobezzza
Copy link

👍

index.js

import './a';
import './b';

a.js

const a = 1, b = 2;

console.log(a, b);

b.js

const a = 2, b = 3;

console.log(a, b);

Command:

rollup rollup/index.js --export umd --id foo --name foo

Output:

const a = 1;
const b = 2;
console.log(a, b);

a$1 = 2; // Error
b$1 = 3; // Error
console.log(a$1, b$1);

@lukeapage
Copy link
Contributor Author

thanks @kobezzza for the repro-case

@Rich-Harris
Copy link
Contributor

Thanks for flagging this up. Looks like the latest version of magic-string is to blame – looking into it

@Rich-Harris
Copy link
Contributor

Fixed in 0.22.2

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

3 participants