Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

ES6 import export #237

Merged
merged 4 commits into from Oct 7, 2015
Merged

ES6 import export #237

merged 4 commits into from Oct 7, 2015

Conversation

MaximSokolov
Copy link
Contributor

@MaximSokolov MaximSokolov commented Oct 6, 2015

Fixes #232

export var x = 0;
export const CONSTANT = 0;
export let scopedVariable = 0;
export function func(p1, p2){}
export class Foo {}
export { bar };
export { bar, foo as alias };
export default "string";
export default 123 + 23;
export default name;
export default function () {}
export default function func() {}
export default class {}
export default class Foo {}
export { foo as default };
export { name } from 'module-name';
export * from 'module-name';
export { default as alias } from 'module-name';
export { default as alias }; //illegal
export { name as * }; //illegal
import "module-name";
import * as name from "module-name"
import defaultMember from "module-name";
import { member } from "module-name";
import { default as defaultMember } from "module-name";
import { member1 , member2 as alias2 } from "module-name";
import { member1 , member2 as default } from "module-name"; //illegal
import { member1 , member2 as * } from "module-name"; //illegal
import defaultMember, { member } from "module-name";
import defaultMember, * as alias from "module-name";
import defaultMember, * as alias from "module-name";

Edit:

#245

export default {
  'prop': 'value'
};

#267

import /* comment */ {
  member1, // comment
  /* comment */
  member2
} from "module-name";

#271

export {
  default as alias // not illegal
} from 'module-name';

#460

import foo
  from 'bar';

atom-dark

Atom Dark

one-dark

One Dark

monokai

Monokai

@Victorystick
Copy link
Contributor

This looks really good! Just one question; is there any reason that the default in Atom Dark and One Dark are highlighted differently in

export { foo as default };
export { default as alias } from 'module-name';

but the same (red) in Monokai?

@MaximSokolov
Copy link
Contributor Author

default, * are variable.language (variables containing default module/all modules):

export * from 'module-name';
import * as name from "module-name"
export { default as defaultMember } from 'module-name';
import { default as defaultMember } from "module-name";

default is storage.modifier:

export default foo;
export { foo as default };

default "modifies" foo i.e. specifies that foo is default module

@Victorystick
Copy link
Contributor

Actually, there was a discussion in an ES forum whether to add an equals sign after export default to make it more obvious that is a special, non-local 'default' variable that is declared using that syntax: export default = foo. So default isn't really a modifier in this case.

In the second case, you export the binding foo from another module under the name default. There is no "modification" going on, just another binding to the same variable.

I therefore think that default should have the scope variable.language in the latter two examples as well.

}
{
'match': ',',
'name': 'punctuation.separator.modules.js'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not meta.delimiter.object.comma.js?

@MaximSokolov
Copy link
Contributor Author

Updated:
atom-dark-2
one-dark-2

@thomasjo
Copy link
Contributor

thomasjo commented Oct 7, 2015

Love it! Unless anyone else has anything to add, this looks ready to 🚢

@Victorystick
Copy link
Contributor

I'm sold. :shipit:

50Wliu added a commit that referenced this pull request Oct 7, 2015
@50Wliu 50Wliu merged commit 0d33d77 into atom:master Oct 7, 2015
@50Wliu
Copy link
Contributor

50Wliu commented Oct 7, 2015

🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants