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

Transformed imports are not hoisted #36

Closed
Conduitry opened this issue Dec 11, 2020 · 0 comments · Fixed by #37
Closed

Transformed imports are not hoisted #36

Conduitry opened this issue Dec 11, 2020 · 0 comments · Fixed by #37
Labels
bug Something isn't working

Comments

@Conduitry
Copy link
Collaborator

Conduitry commented Dec 11, 2020

Upon transforming imports, they are not hoisted to the top of the file, which leads to different meaning/behavior in the original file and the transformed file.

For example,

console.log(foo);
import { foo } from 'bar';

(which is perfectly valid) is transformed to

__shimport__.define('demo.js', ['bar'], function(__import, __exports, __dep_0){ console.log(foo);
var foo = __dep_0.foo; /*import { foo } from 'bar'*/;
});

(which has different behavior from the original code, as foo will still be undefined during the console.log(foo)).

This was, as far as I can tell, the real underlying bug behind sveltejs/sapper#1593 and fixing this would likely be more desirable than the change in sveltejs/sapper#1595 was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant