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

Add direct module.exports #62

Open
zavr-1 opened this issue Jul 21, 2018 · 3 comments
Open

Add direct module.exports #62

zavr-1 opened this issue Jul 21, 2018 · 3 comments

Comments

@zavr-1
Copy link

zavr-1 commented Jul 21, 2018

Instead of exporting module.exports = exports.default; is it possible to add an option to export module.exports = myDefaultVariableName? Because the VS Code does not understand the first option to infer types but works fine with the second one. Thanks.

@yvele
Copy link

yvele commented Sep 19, 2018

This looks like more to be a problem with VS Code 🤔

@gwillz
Copy link

gwillz commented Jan 12, 2019

I think OP's issue still has merit. There is a masking behaviour when using module.exports and exports. It's best to stick to one form per file.

For example:

// plugin.js
module.exports = 'hey';
exports.extra = 'another hey';

// main.js
const hey = require('./plugin');
hey === 'hey';               // => true
hey.extra === 'another hey'; // => false

In this example we've lost the .extra property, because the module.export has a sort of priority. If we were to only use the exports.extra statement, we would be able to access 'another hey'.

@ljharb
Copy link

ljharb commented Jan 12, 2019

I believe this is done so as not to conflict with the modules transform - otherwise order would matter.

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

4 participants