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

Improve library targets #6517

Merged
merged 9 commits into from Jun 29, 2021
Merged

Improve library targets #6517

merged 9 commits into from Jun 29, 2021

Conversation

devongovett
Copy link
Member

@devongovett devongovett commented Jun 26, 2021

Fixes #6110, Fixes #6465, Closes T-1091.

This adds a diagnostic when using an invalid file extension in one of the library targets.

image-2

In addition, it adds support for outputting .mjs and .cjs files, and infers the correct output format. The "type": "module" option in package.json is also supported.

@height
Copy link

height bot commented Jun 26, 2021

This pull request has been linked to and will mark 1 task as "Done" when merged:

💡Tip: You can link multiple Height tasks to a pull request.

@devongovett
Copy link
Member Author

devongovett commented Jun 26, 2021

Should we also infer outputFormat: 'esmodule' or outputFormat: 'commonjs' for custom targets when using a .mjs or .cjs file? Currently I only infer this for common targets. I don't know if type: module should apply there as well? Does node only use it for the "main" field?

@parcel-benchmark
Copy link

parcel-benchmark commented Jun 26, 2021

Benchmark Results

Kitchen Sink 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

React HackerNews ✅

Timings

Description Time Difference
Cold 10.61s -83.00ms
Cached 453.00ms -16.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

Bundle Size Difference Time Difference
dist/logo.1e014c76.png 274.00b +0.00b 312.00ms -37.00ms 🚀

AtlasKit Editor 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

Three.js ✅

Timings

Description Time Difference
Cold 7.53s -30.00ms
Cached 392.00ms -21.00ms 🚀

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@devongovett
Copy link
Member Author

Added additional diagnostics:

  • disallow global output format for library targets
  • handle mismatch between declared output format and inferred
  • disallow ESM output in main field without .mjs extension or "type": "module" field

@devongovett devongovett merged commit 187ddfd into v2 Jun 29, 2021
@devongovett devongovett deleted the common-target-improvements branch June 29, 2021 02:30
lettertwo added a commit that referenced this pull request Jul 13, 2021
* v2: (34 commits)
  Wrap assets recursively when any incoming dependency is wrapped (#6572)
  Improvements for library targets (#6570)
  Diagnostic for undeclared external dependencies in library builds (#6564)
  More bugs (#6567)
  Don't require `url:` for image transformer (#6565)
  Remove 'Name already registered with serializer' error (#6566)
  Fix live bindings and `this` of external CommonJS modules (#6548)
  JS runtime improvements (#6531)
  Make sure the absolute path isn't contained in the cache (#5900)
  Adds '@parcel/diagnostic' to dependencies (#6563)
  Disable workers with string literals and improve diagnostics (#6536)
  Bug fixes (#6541)
  Don't attempt to resolve URLs starting with '#' (#6504)
  Correctly set worker's output format if not support by environment (#6534)
  Babel: Recognize peerDependencies in isJSX (#6497)
  fix setHeaders ordering on dev server (#6500)
  Graph: Remove Node interface (#6530)
  Fix TS build script for old Node versions (#6526)
  Improve library targets (#6517)
  Fix TypeScript and other sourcemaps by always creating an initial sourcemap (#6472)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants