Comments (4)
hey @anandthakker, thanks for the detailed bug report. I've published v0.14.0
that includes a fix for this case. Could you please check if it helps? I'll close the issue, please feel free to reopen if anything else goes wrong.
from amd-to-es6.
I think this fixes the reported issue but now we just need to add one additional step to introduce another issue:
Start with
define(["require", "exports"], function (require, exports) {
"use strict";
if (false) {}
var Foo = function () {};
exports.default = Foo;
});
Actual Results
(function () {
if (false) {}
var Foo = function () {};
})();
var a = Foo;
export {a as default};
Notice that var Foo
is declared within the IIFE so it cannot be accessed in this way.
Expected results
I'm not exactly sure what the expected results should be. Maybe:
var a;
(function () {
if (false) {}
var Foo = function () {};
a = Foo
})();
export {a as default};
from amd-to-es6.
Thanks, makes sense, I wasn't sure what's the real life scenario here. It's probably fine to drop the iife completely in this case. I'll push an another fix tomorrow
from amd-to-es6.
@mikehaverstock I've pushed the other fix and released as v0.14.1
. It's not ideal but it should hopefully handle this case a bit better.
from amd-to-es6.
Related Issues (20)
- Preserve line breaks HOT 1
- If an AMD Module nests a return statement below the conditionals, then the return doesn't become an export. HOT 2
- Failure to process Kotlin JS/exports correctly HOT 1
- fails on ES6 modules with dynamic imports HOT 4
- Async/await HOT 2
- top level this and undefined HOT 2
- Comments retention support HOT 1
- require assignments not converted to imports when declaration separation from assignment
- Bring back two flaky cli tests
- proxy modules do not get converted HOT 1
- cannot access members of require calls inline HOT 1
- "Await expression not allowed in formal parameter" HOT 2
- Quotes option in non-cli HOT 3
- Transpiling fails when using with optional chaining
- Credit
- abstract-syntax-tree is broken due to meriyah HOT 2
- can transform cmd to es6? HOT 6
- cli always using double quotes
- Nested ES classes with constructors not supported
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amd-to-es6.