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

Uglified AMD modules aren't always properly converted #33

Open
jslegers opened this issue Mar 19, 2019 · 2 comments
Open

Uglified AMD modules aren't always properly converted #33

jslegers opened this issue Mar 19, 2019 · 2 comments

Comments

@jslegers
Copy link

Take the following AMD module :

define([
  "./Promise",
  "./request"
], function(Promise,
            request) {

  return {
    func1: function(v1) {
    },
    func2: function(v1) {
    }
  };
});

This module is succesfully converted to the following format :

import Promise from "./Promise";
import request from "./request";

  export default {
    func1: function(v1) {
    },
    func2: function(v1) {
    }
  };

However, consider the same code, but uglified :

define(["./Promise","./request"],function(n,u){return{func1:function(n){},func2:function(n){}}});

If I now try to convert to ES6 modules, it produces the following incorrect output :

import n from "./Promise";
import u from "./request";return{func1:function(n){},func2:function(n){}}
@jonbretman
Copy link
Owner

Hey, I'm not sure why this is happening but my first question would be why are you running this against uglified code? The intention of this package to convert source code written in AMD format to ES6 style imports as a one-time operation to help with migration from the former to the latter.

Does this make sense?

@jslegers
Copy link
Author

jslegers commented Mar 28, 2019

Here at Luciad, we are currently in the process of moving our LuciadRIA library away from AMD to ES6. And the code that we ship to our customers is minified.

My first attempts to use this project were done on one of our official releases. And, because this code was minified, it produced incorrect output.

Also, to make our code fully ES6-compatible, I will need to strip out all AMD-specific code, such as require.toUrl or the "exports" module identifier (as they don't have ES6 equivalent) before I convert all of our dev code to ES6. And not being able to use our release for testing makes this quite a painful process.

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

2 participants