Skip to content

Refactor build and package layout - #282

Merged
ericf merged 1 commit into
formatjs:masterfrom
ericf:package-improvements
Jan 14, 2016
Merged

ericf merged 1 commit into
formatjs:masterfrom
ericf:package-improvements

Conversation

@ericf

@ericf ericf commented Jan 13, 2016

Copy link
Copy Markdown
Collaborator

This is a major refactor of React Intl's build and npm package layout.

Locale data is now package-relative and can more easily be loaded:

import enLocaleData from 'react-intl/locale-data/en';

There is now only one copy of these locale data files in the package and they are UMD modules which export the locale data for a language.

Rollup is now being used to build a single-file React Intl module for three different targets:

  • UMD (ReactIntl global): Browser build with bundled dependencies
  • CommonJS (main): For Node/Browserify/Webpack with require()-d dependencies
  • ES6 (jsnext:main): For consumption via import with import-d dependencies

All of the builds are compiled with Babel and bundled into a single module file. Rollup is used to fold all of the internal src/ modules into one. The difference between lib/index.js and lib/index.es.js is the latter has everything compiled expect the import/export statements for React Intl as a whole package.

The .babelrc files have been moved to closer to the source code which they apply. This allows for test or example code to leverage experimental ECMAScript syntax without leaking it into the main src.

These changes should result is a smaller and faster package as all of React Intl's code is folded into a single module scope, and the Babel helpers are only included once (instead of per module file). As well as fixing support for IE8.

Fixes #203
Fixes #204
Fixes #275
Fixes #277

@ericf
ericf force-pushed the package-improvements branch from 1dc62da to 3575e9e Compare January 13, 2016 00:35
@ericf ericf mentioned this pull request Jan 13, 2016
7 tasks done
@ericf
ericf force-pushed the package-improvements branch from 3575e9e to 5f1397f Compare January 13, 2016 00:54
This is a major refactor of React Intl's build and npm package
layout.

Locale data is now package-relative and can more easily be loaded:
```js
import enLocaleData from 'react-intl/locale-data/en';
```

There is now only one copy of these locale data files in the package
and they are UMD modules which export the locale data for a language.

Rollup is now being used to build a _single-file_ React Intl module
for three different targets:

- `ReactIntl` global: Browser build with bundled dependencies
- CommonJS (`main`): For Node/Browserify/Webpack with `require()`-d
dependencies
- ES6 (`jsnext:main`): For consumption via `import` with `import`-d
dependencies

All of the builds are compiled with Babel and bundled into a single
module file. Rollup is used to fold all of the internal `src/`
modules into one. The difference between `lib/index.js` and
`lib/index.es.js` is the latter has everything compiled expect the
`import`/`export` statements for React Intl as a whole package.

The `.babelrc` files have been moved to closer to the source code
which they apply. This allows for test or example code to leverage
experimental ECMAScript syntax without leaking it into the main src.

These changes should result is a smaller and faster package as all of
React Intl's code is folded into a single module scope, and the Babel
helpers are only included once (instead of per module file). As well
as fixing support for IE8.

Fixes formatjs#203
Fixes formatjs#204
Fixes formatjs#275
Fixes formatjs#277
@ericf
ericf force-pushed the package-improvements branch from 5f1397f to 36bd26e Compare January 14, 2016 05:08
ericf added a commit that referenced this pull request Jan 14, 2016
Refactor build and package layout
@ericf
ericf merged commit 196d098 into formatjs:master Jan 14, 2016
@ericf
ericf deleted the package-improvements branch January 14, 2016 17:06
@SimenB

SimenB commented Jan 14, 2016

Copy link
Copy Markdown

Sweet! A timeline for the release of a IE8-compatible version? 😄

It'd be great to add it to the current feature we're building

@ericf

ericf commented Jan 14, 2016

Copy link
Copy Markdown
Collaborator Author

@SimenB blocked by this: rollup/rollup-plugin-babel#34

Writing functional tests right to test the builds which catch the issue in that PR.

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

Labels

None yet

Projects

None yet

2 participants