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

Add support for experimentalCodeSplitting from Rollup 0.55.0 #283

Merged
merged 3 commits into from
Jan 26, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export default function commonjs ( options = {} ) {
() => false;

let entryModuleIdsPromise = null;
const entryModuleIds = [];

function resolveId ( importee, importer ) {
if ( importee === HELPERS_ID ) return importee;
Expand Down Expand Up @@ -135,11 +134,7 @@ export default function commonjs ( options = {} ) {

const entryModules = [].concat( options.input || options.entry );
entryModuleIdsPromise = Promise.all(
entryModules.map( entry =>
resolveId( entry ).then( resolved => {
entryModuleIds.push( resolved );
})
)
entryModules.map( entry => resolveId( entry ))
);
Copy link
Member

Choose a reason for hiding this comment

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

Minor totally unimportant nit: This looks a little more confusing as it needs to be (and it can possibly shuffle the order of the entry points which may or may not cause someone to stumble over this again in the future). If you Promise.all the mapped entryModules first and then assign the resulting array to entryModuleIds, the order would be preserved and one would not stop for a second to wonder if entryModuleIds really is a permuted map of entryModules 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally fair, I have updated the code to be more succinct and to use the result of the entryModuleIdsPromise.

},

Expand Down Expand Up @@ -173,7 +168,7 @@ export default function commonjs ( options = {} ) {
if ( !filter( id ) ) return null;
if ( extensions.indexOf( extname( id ) ) === -1 ) return null;

return entryModuleIdsPromise.then( () => {
return entryModuleIdsPromise.then( (entryModuleIds) => {
Copy link
Member

Choose a reason for hiding this comment

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

That was quick. Yes, that's even better!

const {isEsModule, hasDefaultExport, ast} = checkEsModule( code, id );
if ( isEsModule ) {
if ( !hasDefaultExport )
Expand Down