esm-to-cjs icon indicating copy to clipboard operation
esm-to-cjs copied to clipboard

Import only is not supported

Open baihuibo opened this issue 4 years ago • 1 comments

Hello, I encountered some problems while experiencing the conversion function

case 1 Import only is not supported

// input
import "lib";

// what i wanted
require("lib");

// actual:ParseError

case 2 Single and double quotation marks should be mixed

// input
import mod from "mod";
import foo from 'foo';

// what i wanted
const mod = require("mod");
const foo = require("foo");

case 3 export mix

// input
export function foo(){}
exports.bar = function (){}

// what i wanted
function foo(){}
exports.bar = function (){}
exports.foo = foo;

// actual
function foo(){}
exports.bar = function (){}
module.exports = { // covered
  foo
};

baihuibo avatar Sep 23 '21 02:09 baihuibo

Hi, I don't actively maintain this project anymore, but I'm happy to review and accept PRs.

Case 1: PR welcome, should we straightforward. Case 2: This would be a little difficult how the parser is written (it's very ad-hoc, not advised for production env; this was a tiny hobby project). Case 3: That's probably something this project shouldn't plan to support.

sidvishnoi avatar Jan 13 '22 11:01 sidvishnoi