Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Test proposals #2

@reconbot

Description

@reconbot

I know it's probably early for this but I worked up the test cases for imports and exports of how I think CommonJS to es modules might look.

https://gist.github.com/reconbot/5358ab4a532d2f253df0

// CommonJS to ES modules test cases

// Importing

var foo = require('bar');
// becomes 
import foo from 'bar';

require('bar')(foo);
// becomes
import tempvar from 'bar';
tempvar(foo);

var foo = require('bar').foo;
// becomes
import {foo} from 'bar';


// Exporting

module.exports = { //pojo
  name: 'todd',
  value: 'person'
};
//becomes
export var name = 'todd';
export var value = 'person';
export default {name, value};

module.exports = function(){}; // or anything not a pojo
//becomes
export default function(){};

module.exports.name = 'todd';
module.exports.value = 'person';
// becomes 
export var name = 'todd';
export var value = 'person';
export default {name, value};

I think this would cover all commonJS use cases but I'm not sure. And the last import example is a nice to have.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions