Skip to content

Commit

Permalink
Fix app.js template.
Browse files Browse the repository at this point in the history
- Previous commit failed because the app.js template was not formatted
properly
  • Loading branch information
Colby Adams committed Feb 23, 2020
1 parent 0ad9c42 commit c00081e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion internals/generators/language/add-locale-data.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$1 import('@formatjs/intl-relativetimeformat/dist/locale-data/{{language}}'),
$1 import('@formatjs/intl-relativetimeformat/dist/locale-data/{{language}}'),
2 changes: 1 addition & 1 deletion internals/generators/language/intl-locale-data.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$& import('@formatjs/intl-pluralrules/dist/locale-data/{{language}}'),
$& import('@formatjs/intl-pluralrules/dist/locale-data/{{language}}'),
45 changes: 31 additions & 14 deletions internals/templates/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,40 @@ const render = () => {
ReactDOM.render(<ConnectedApp />, MOUNT_NODE);
};

if (module.hot) {
// Hot reloadable React components and translation json files
// Hot reloadable translation json files
// modules.hot.accept does not accept dynamic dependencies,
// have to be constants at compile-time
module.hot.accept(['./i18n'], () => {
ReactDOM.unmountComponentAtNode(MOUNT_NODE);
render();
});
}

// Chunked polyfill for browsers without Intl support
if (!window.Intl) {
if (!Intl.PluralRules || !Intl.RelativeTimeFormat) {
new Promise(resolve => {
resolve(
Promise.all([
import('@formatjs/intl-pluralrules/polyfill'),
import('@formatjs/intl-relativetimeformat/polyfill'),
]),
);
if (!Intl.PluralRules) {
resolve(
Promise.all([
import('@formatjs/intl-pluralrules/polyfill'),
import('@formatjs/intl-pluralrules/dist/locale-data/en'),
]),
);
} else {
resolve();
}
})
.then(() =>
Promise.all([
import('@formatjs/intl-pluralrules/dist/locale-data/en'),

import('@formatjs/intl-relativetimeformat/dist/locale-data/en'),
]),
) // eslint-disable-line prettier/prettier
.then(() => {
if (!Intl.RelativeTimeFormat) {
return Promise.all([
import('@formatjs/intl-relativetimeformat/polyfill'),
import('@formatjs/intl-relativetimeformat/dist/locale-data/en'),
]);
}
return Promise.resolve();
}) // eslint-disable-line prettier/prettier
.then(() => render())
.catch(err => {
throw err;
Expand Down

0 comments on commit c00081e

Please sign in to comment.