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

Separate typings for node and browser #10

Merged
merged 2 commits into from
Jul 9, 2018
Merged

Conversation

frenzzy
Copy link
Member

@frenzzy frenzzy commented Jul 9, 2018

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov
Copy link

codecov bot commented Jul 9, 2018

Codecov Report

Merging #10 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #10   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      3           
  Lines          91     91           
  Branches       18     18           
=====================================
  Hits           91     91
Impacted Files Coverage Δ
src/node.js 100% <100%> (ø) ⬆️
src/browser.js 100% <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 afe35a5...9f70b5f. Read the comment docs.

@frenzzy frenzzy mentioned this pull request Jul 9, 2018
9 tasks
@@ -17,39 +17,40 @@
],
"main": "node/index.js",
"module": "node/module.js",
"typings": "render.d.ts",
"typings": "src/node.d.ts",
Copy link
Contributor

@joseluisq joseluisq Jul 9, 2018

Choose a reason for hiding this comment

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

Why "typings": "src/node.d.ts"? Why not "typings": "src/index.d.ts"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, ignore it. src/node.d.ts makes more sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

  • index.{js,d.ts} - common code for node and browser which exports internal renderer and renderToString
  • browser.{js,d.ts} - client-side code which re-exports renderToString from index and exports withRender with toString only
  • node.{js,d.ts} - server-side code which re-exports renderToString from index plus renderToStream and also exports withRender with toString and toStream

Copy link
Contributor

Choose a reason for hiding this comment

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

But I think that App interface should be in Hyperapp package. In fact app() function has the same definition. It makes more sense for me refers from Hyperapp. Because now you have two App interfaces (both are the same).

Copy link
Contributor

@joseluisq joseluisq Jul 9, 2018

Choose a reason for hiding this comment

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

In short, App is the type for one app() function that withRender() will need as param.

Copy link
Contributor

@joseluisq joseluisq Jul 9, 2018

Choose a reason for hiding this comment

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

index.{js,d.ts} - common code for node and browser which exports internal renderer and renderToString
browser.{js,d.ts} - client-side code which re-exports renderToString from index and exports withRender with toString only
node.{js,d.ts} - server-side code which re-exports renderToString from index plus renderToStream and also exports withRender with toString and toStream

Great!

Copy link
Contributor

Choose a reason for hiding this comment

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

Only a detail about importing.
Here some examples:

// 1. Testing:
import { renderToStream, withRender, Render, renderToString } from "../../src/node"
// 2. Actually: if I want to import node version
import { renderToStream, withRender, Render, renderToString } from "@hyperapp/render/src/node"
// 3. Purpose: move typings to root directory
import { renderToStream, withRender, Render, renderToString } from "@hyperapp/render/node"

Why do you think about the third option?

Copy link
Member Author

@frenzzy frenzzy Jul 9, 2018

Choose a reason for hiding this comment

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

Both 2 and 3 options are valid!
They already work in current v2.0.0 and after this PR will work with typings 🎉

Copy link
Contributor

Choose a reason for hiding this comment

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

fine!

Copy link
Contributor

Choose a reason for hiding this comment

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

The PR was sent..

@frenzzy frenzzy merged commit e8f1358 into master Jul 9, 2018
@frenzzy frenzzy deleted the typings-node-browser branch July 9, 2018 21:39
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.

2 participants