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

fix: avoid ES6 export for entry files w/o exports #351

Merged
merged 1 commit into from Nov 25, 2019

Conversation

opichals
Copy link
Contributor

@opichals opichals commented Nov 6, 2018

No ES6 export is added to entry files containing no CommonJS export.

E.g. this entry file named xyz/index.js containing

var dummy = require('./dummy');
var input = 42;

This PR makes the above code which doesn't contain any exports use transformed into the following containing no ES6 export:

import './dummy';
import dummy from 'commonjs-proxy:./dummy';
var input = 42;

In master branchy it adds an empty object module.exports clause which is useful for non-entry files but not desirable for entry files:

import './dummy';
import dummy from 'commonjs-proxy:./dummy';
var input = 42;

var xyz = {

};

module.exports = xyz;

opichals added a commit to opichals/rollup-plugin-espruino-modules that referenced this pull request Nov 7, 2018
@shellscape
Copy link
Contributor

Thanks for opening this PR and I'm sorry that it didn't get the attention that it needed. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and that should mean all the plugins get more TLC moving forward.

I resolved the conflicts in your PR but it looks like there are some issue with CI. If you can clean those up this week, we'll take a look at getting this merged. If not, no worries, a new PR will be welcome at the new repo.

@opichals opichals force-pushed the no-export-default-if-none-found branch 2 times, most recently from 7aa864f to 64a343d Compare November 25, 2019 07:31
No ES6 export is added to _entry_ files containing no CommonJS export.

E.g. this:
```
var dummy = require('./dummy');
var input = 42;
```

Is now transformed into the following containing no ES6 export:
```
import './dummy';
import dummy from 'commonjs-proxy:./dummy';
var input = 42;
```
@opichals opichals force-pushed the no-export-default-if-none-found branch from 64a343d to 8048cdf Compare November 25, 2019 08:09
@opichals
Copy link
Contributor Author

@shellscape Thank you! I have rebased this and adapted to work on top of master.

@shellscape
Copy link
Contributor

Cheers 🍺 Thanks

@shellscape shellscape merged commit 535e811 into rollup:master Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants