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: add ES5 build using ES2015 modules #55

Merged
merged 2 commits into from Sep 29, 2017

Conversation

Projects
None yet
1 participant
@alexandru
Member

alexandru commented Sep 29, 2017

Fixes #52.

This PR provides bundles compatible with ES5 + ES2015 modules (instead of UMD / CommonJS).
This allows tools like Webpack to work without requiring a separate Babel-enabled compilation step or other expensive setup.

Unfortunately we cannot add ES5 as the default build indicated by the module entry in package.json, therefore the default build remains the ES2015 build. This is because:

  1. the ES5 compatibility requirement is only temporary, current versions of Firefox, Chrome and Safari already support all of ES2015, see: https://kangax.github.io/compat-table/es6/
  2. ES5 code loses info that could be used by minifiers and has auto-generated junk in it for supporting features (e.g. class inheritance, async generators, etc.) which can generate conflicts

The solution is to provide a separate ES5 build that can be used like this when doing a la carte dependency management:

// funfix-core
import { Option } from "funfix-core/dist/es5"

// funfix-exec
import { Future } from "funfix-exec/dist/es5"

// funfix-effect
import { IO } from "funfix-effect/dist/es5"

// funfix-types
import { Monad } from "funfix-types/dist/es5"

Note that because of the way the TypeScript / JavaScript toolchain works, you may experience issues, because when doing testing with Mocha or Jest by means of say ts-node, the ES2015 imports end up using CommonJS under the hood (since they are running on top of Node) and thus don't expect ES2015 modules.

Or you can see weird type mismatch errors, the compiler seeing the same type name imported from different places. An easy fix for this particular issue is to use the main funfix dependency, which includes everything in the UMD and ES5 bundles:

import * as ff from "funfix/dist/es5"

All of this isn't the fault of Funfix, but of the way the JS tool-chain works. If you experience issues, drop on the Gitter channel to see what we can do.

Welcome to the hell that is JavaScript dependency management! This PR fixes one issue related to it. Probably more to come.

@codecov

This comment has been minimized.

Show comment
Hide comment
@codecov

codecov bot Sep 29, 2017

Codecov Report

Merging #55 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #55   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          24     24           
  Lines        2470   2470           
  Branches      393    393           
=====================================
  Hits         2470   2470
Impacted Files Coverage Δ
packages/funfix-effect/src/index.ts 100% <ø> (ø) ⬆️
packages/funfix-types/src/instances.ts 100% <ø> (ø) ⬆️
packages/funfix-effect/src/io.ts 100% <ø> (ø) ⬆️
packages/funfix-core/src/errors.ts 100% <ø> (ø) ⬆️
packages/funfix-exec/src/future.ts 100% <ø> (ø) ⬆️
packages/funfix-types/src/applicative.ts 100% <ø> (ø) ⬆️
packages/funfix-core/src/std.ts 100% <ø> (ø) ⬆️
packages/funfix-exec/src/ref.ts 100% <ø> (ø) ⬆️
packages/funfix-core/src/index.ts 100% <ø> (ø) ⬆️
packages/funfix-exec/src/index.ts 100% <ø> (ø) ⬆️
... and 14 more

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 1c0a61d...6b29d81. Read the comment docs.

codecov bot commented Sep 29, 2017

Codecov Report

Merging #55 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #55   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          24     24           
  Lines        2470   2470           
  Branches      393    393           
=====================================
  Hits         2470   2470
Impacted Files Coverage Δ
packages/funfix-effect/src/index.ts 100% <ø> (ø) ⬆️
packages/funfix-types/src/instances.ts 100% <ø> (ø) ⬆️
packages/funfix-effect/src/io.ts 100% <ø> (ø) ⬆️
packages/funfix-core/src/errors.ts 100% <ø> (ø) ⬆️
packages/funfix-exec/src/future.ts 100% <ø> (ø) ⬆️
packages/funfix-types/src/applicative.ts 100% <ø> (ø) ⬆️
packages/funfix-core/src/std.ts 100% <ø> (ø) ⬆️
packages/funfix-exec/src/ref.ts 100% <ø> (ø) ⬆️
packages/funfix-core/src/index.ts 100% <ø> (ø) ⬆️
packages/funfix-exec/src/index.ts 100% <ø> (ø) ⬆️
... and 14 more

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 1c0a61d...6b29d81. Read the comment docs.

@alexandru alexandru merged commit 3e94c9e into master Sep 29, 2017

4 checks passed

codecov/patch Coverage not affected when comparing 1c0a61d...6b29d81
Details
codecov/project 100% remains the same compared to 1c0a61d
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@alexandru alexandru changed the title from feat: add ES5 build using ES2015 modules (for Webpack usage) to feat: add ES5 build using ES2015 modules Sep 29, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment