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

[v2.0.0] Remove @types dependencies #3395

Merged
merged 3 commits into from Feb 26, 2020

Conversation

lukastaegert
Copy link
Member

@lukastaegert lukastaegert commented Feb 21, 2020

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:
Resolves #3108, #2142

Description

I hope this is the last change that is going into 2.0.0.
One problem that was reported repeatedly is that Rollup's dependency on @types/node was causing issues for users that were not targeting Node but had conflicting types such as AMD or browser types. Moreover it was not clear why non-TypeScript-users would need to have external type dependencies.

One suggestion was to make the types a peerDependency but in our opinion this would have caused unnecessary friction for TypeScript users. This PR finally fixes this by getting rid of the @types dependencies the following way:

  • The only Node type we needed for our external interface was Buffer. A Node Buffer however is a sub-class of UInt8Array, which is a standard JS type and still very powerful. So this replaces Buffer everywhere with UInt8Array.
  • Even though we had ESTree types in our public interface, we only had acorn.Node as a type internally. This PR replaces all ESTree.Node types with a simplified, copied version of acorn.Node that reflects the properties present on all nodes. Note that you will need type casts if you need to access properties of specific node types.

I also made sure that the typings test for the public interface that we have in place will ignore all @types packages that come from our dev dependencies and will thus ensure that we do not accidentally add a dependency on @types/node to the published artefact.

@lukastaegert lukastaegert changed the base branch from master to release-2.0.0 February 21, 2020 09:00
@codecov
Copy link

codecov bot commented Feb 21, 2020

Codecov Report

Merging #3395 into release-2.0.0 will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@              Coverage Diff              @@
##           release-2.0.0   #3395   +/-   ##
=============================================
  Coverage             95%     95%           
=============================================
  Files                171     171           
  Lines               5801    5801           
  Branches            1712    1712           
=============================================
  Hits                5511    5511           
  Misses               157     157           
  Partials             133     133
Impacted Files Coverage Δ
cli/run/build.ts 82.5% <ø> (ø) ⬆️
src/rollup/rollup.ts 100% <ø> (ø) ⬆️
src/utils/PluginContext.ts 100% <ø> (ø) ⬆️
src/Graph.ts 97.35% <ø> (ø) ⬆️
src/Module.ts 97.93% <ø> (ø) ⬆️
src/utils/transform.ts 98.43% <ø> (ø) ⬆️
src/utils/fs.ts 70.58% <ø> (ø) ⬆️
src/utils/pureComments.ts 100% <100%> (ø) ⬆️
src/ModuleLoader.ts 98.52% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bbfe4a5...0bf38a5. Read the comment docs.

@rollup-bot
Copy link
Collaborator

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#2.0.0-remove-type-dependencies

or load it into the REPL:
https://rollupjs.org/repl/?circleci=9466

@lukastaegert lukastaegert changed the title [v2.0.0] Remove type dependencies [v2.0.0] Remove @type dependencies Feb 21, 2020
@lukastaegert lukastaegert changed the title [v2.0.0] Remove @type dependencies [v2.0.0] Remove @types dependencies Feb 21, 2020
@lukastaegert lukastaegert merged commit 1e393ef into release-2.0.0 Feb 26, 2020
@lukastaegert lukastaegert deleted the 2.0.0-remove-type-dependencies branch February 26, 2020 06:23
@lukastaegert lukastaegert mentioned this pull request Feb 26, 2020
9 tasks
lukastaegert added a commit that referenced this pull request Feb 26, 2020
* Replace Buffer with UInt8Array and get rid of Node types dependency

* Git rid of ESTree dependency by using a specialized version of acorn's Node type

* Fix test and adjust documentation
lukastaegert added a commit that referenced this pull request Mar 6, 2020
* Replace Buffer with UInt8Array and get rid of Node types dependency

* Git rid of ESTree dependency by using a specialized version of acorn's Node type

* Fix test and adjust documentation
lukastaegert added a commit that referenced this pull request Mar 6, 2020
* Replace Buffer with UInt8Array and get rid of Node types dependency

* Git rid of ESTree dependency by using a specialized version of acorn's Node type

* Fix test and adjust documentation
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

Successfully merging this pull request may close these issues.

@types packages should be peerDependencies
2 participants