From 57a7e419ef782650597c4f51bd78472c8b365aa3 Mon Sep 17 00:00:00 2001 From: Max Lapides Date: Wed, 13 Dec 2017 13:39:48 -0800 Subject: [PATCH] Updated documentation example for webpack 3 --- README.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f3e20fabb..23095afa0 100644 --- a/README.md +++ b/README.md @@ -73,18 +73,17 @@ built-in `Intl`. An example of conditional usage using [webpack][] _might_ look ```javascript function runMyApp() { - var nf = new Intl.NumberFormat(undefined, {style:'currency', currency:'GBP'}); - document.getElementById('price').textContent = nf.format(100); + var nf = new Intl.NumberFormat(undefined, { + style: 'currency', + currency: 'GBP' + }) + document.getElementById('price').textContent = nf.format(100) } -if (!global.Intl) { - require.ensure([ - 'intl', - 'intl/locale-data/jsonp/en.js' - ], function (require) { - require('intl'); - require('intl/locale-data/jsonp/en.js'); - runMyApp() - }); +const selectedLocale = 'en' +if (!window.Intl) { + import('intl') + .then(() => import(`intl/locale-data/jsonp/${selectedLocale}.js`)) + .then(runMyApp) } else { runMyApp() }