Skip to content
This repository was archived by the owner on Jun 1, 2024. It is now read-only.

feat: add ES5 build using ES2015 modules #55

Merged
merged 2 commits into from
Sep 29, 2017
Merged

feat: add ES5 build using ES2015 modules #55

merged 2 commits into from
Sep 29, 2017

Conversation

alexandru
Copy link
Member

@alexandru 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
Copy link

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
@alexandru alexandru changed the title feat: add ES5 build using ES2015 modules (for Webpack usage) feat: add ES5 build using ES2015 modules Sep 29, 2017
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.

Distribute ES5 instead of ES2015
1 participant