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

feat(react): provide only umd & esm bundles when packaging #2524

Merged
merged 2 commits into from
Feb 24, 2020

Conversation

rarmatei
Copy link
Collaborator

@rarmatei rarmatei commented Feb 21, 2020

Current Behavior (This is the behavior we have today, before the PR is merged)

When building libraries for the web, we export 3 bundles:

  • umd
  • esm2015
  • esm5

Expected Behavior (This is the new behavior we can expect after the PR is merged)

We don't really need to transpile at all (the consumer of the library can be responsible for that). Instead, we should just be exporting a UMD bundle (for backwards compatibility) and a ESM bundle.

Issue

Closes #2496 - because we don't need to set a targets anymore, which works around a babel bug

@rarmatei rarmatei requested a review from jaysoo February 21, 2020 11:18
tap({
complete: () => {
updatePackageJson(options, context, target, dependencies);
context.logger.info('Bundle complete.');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

previously, if compilation (or anything else) failed, we'd still generate a dist folder with a package.json

paths: parsedTSConfig.compilerOptions.paths
}
}
}),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we want to invoke the typescript compiler each time, so it can fail the build if something is wrong

Copy link
Member

Choose a reason for hiding this comment

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

Make sense. I just wanna check to make sure the type error is only printed once rather than multiple times.

Copy link
Member

Choose a reason for hiding this comment

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

I tested the build and it does output the same errors twice (e.g. type errors) if both rollup runs fail the same way. See my other comment for more on this.

#2524 (comment)

compilerOptions: {
rootDir: options.entryRoot,
allowJs: false,
declaration: index === 0,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we only want to emit the declaration files the first time

return {
success: acc.success && result.success
};
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I found an issue here with a race condition: if one of the later rollup bundles failed and the first one succeeded, it would still mark the bundle as a success

solution was to separate it into a mergeMap followed by a scan --> this way we still keep the parallelism of the bundle generators, but we correctly reduce the final result

I made a stackblitz here to show the issue: https://stackblitz.com/edit/rxjs-cqwcxx

@jaysoo jaysoo merged commit bdaf298 into nrwl:master Feb 24, 2020
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
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.

react library build failed
2 participants