Skip to content

Commit 336d365

Browse files
author
Long Ho
committed
fix: rm rollup for core, reduce @types/react version
fix docs to exclude core
1 parent 223d2cf commit 336d365

File tree

4 files changed

+6
-32
lines changed

4 files changed

+6
-32
lines changed

docs/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ There are a few API layers that React Intl provides and is built on. When using
77
- [ECMAScript Internationalization API](#ecmascript-internationalization-api)
88
- [FormatJS Internationalization Formatters](#formatjs-internationalization-formatters)
99
- [React Intl API](#react-intl-api)
10-
- [`defineMessages`](#definemessages)
10+
- [`defineMessages`](#definemessages)
1111
- [Injection API](#injection-api)
1212
- [`useIntl` hook (currently available in 3.0.0 beta)](#useintl-hook-currently-available-in-300-beta)
1313
- [`injectIntl` HOC](#injectintl-hoc)

docs/Advanced-Usage.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44

55
<!-- toc -->
66

7-
- [Core `react-intl` & pre-parsing messages](#core-react-intl--pre-parsing-messages)
7+
- [Pre-parsing messages](#core-react-intl--pre-parsing-messages)
88
- [Caveats](#caveats)
99
- [Imperative APIs](#imperative-apis)
1010

1111
<!-- tocstop -->
1212

13-
## Core `react-intl` & pre-parsing messages
13+
## Pre-parsing messages
1414

15-
We've also provided a core package that has the same API as the full `react-intl` package but without our parser. What this means is that you would have to pre-parse all messages into `AST` using [`intl-messageformat-parser`](https://www.npmjs.com/package/intl-messageformat-parser) and pass that into `IntlProvider`.
16-
17-
This is especially faster since it saves us time parsing `string` into `AST`. The use cases for this support are:
15+
You can also pre-parse all messages into `AST` using [`intl-messageformat-parser`](https://www.npmjs.com/package/intl-messageformat-parser) and pass that into `IntlProvider`. This is especially faster since it saves us time parsing `string` into `AST`. The use cases for this support are:
1816

1917
1. Server-side rendering or pre-parsing where you can cache the AST and don't have to pay compilation costs multiple time.
2018
2. Desktop apps using Electron or CEF where you can preload/precompile things in advanced before runtime.
@@ -31,7 +29,7 @@ const messages = {
3129

3230
// During runtime
3331
// ES6 import
34-
import {IntlProvider, FormattedMessage} from 'react-intl/core';
32+
import {IntlProvider, FormattedMessage} from 'react-intl';
3533
import * as ReactDOM from 'react-dom';
3634

3735
ReactDOM.render(
@@ -41,18 +39,10 @@ ReactDOM.render(
4139
); // will render `hello world`
4240
```
4341

44-
The package size is also roughly 30% smaller:
45-
46-
| Package | Minified Size | Minzipped Size |
47-
| ----------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
48-
| `react-intl` | ![minified size](https://badgen.net/badgesize/normal/https://unpkg.com/react-intl@next/dist/react-intl.min.js) | ![minzipped size](https://badgen.net/badgesize/gzip/https://unpkg.com/react-intl@next/dist/react-intl.min.js) |
49-
| `react-intl/core` | ![core min size](https://badgen.net/badgesize/normal/https://unpkg.com/react-intl@next/dist/react-intl-core.min.js) | ![core minzipped size](https://badgen.net/badgesize/gzip/https://unpkg.com/react-intl@next/dist/react-intl-core.min.js) |
50-
5142
### Caveats
5243

5344
- Since this approach uses `AST` as the data source, changes to `intl-messageformat-parser`'s `AST` will require cache invalidation
5445
- `AST` is also larger in size than regular `string` messages but can be efficiently compressed
55-
- Since `react-intl/core` does not have a parser, it will not be able to process string-based `defaultMessage` (will render the string as is w/o any token value replacement).
5646

5747
## Imperative APIs
5848

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@formatjs/intl-relativetimeformat": "^2.5.0",
4040
"@types/hoist-non-react-statics": "^3.3.1",
4141
"@types/invariant": "^2.2.30",
42-
"@types/react": "^16.8.24",
42+
"@types/react": "^16.0.0",
4343
"hoist-non-react-statics": "^3.3.0",
4444
"intl-format-cache": "^4.1.4",
4545
"intl-locales-supported": "^1.4.2",

rollup.config.dist.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,4 @@ export default [
5252
external: ['react'],
5353
plugins,
5454
},
55-
{
56-
input: p.resolve('lib/core.js'),
57-
output: {
58-
file: p.resolve(`dist/react-intl-core.${isProduction ? 'min.js' : 'js'}`),
59-
format: 'umd',
60-
name: 'ReactIntl',
61-
banner: copyright,
62-
exports: 'named',
63-
sourcemap: true,
64-
globals: {
65-
react: 'React',
66-
},
67-
},
68-
external: ['react'],
69-
plugins,
70-
},
7155
];

0 commit comments

Comments
 (0)