alibaba / react-intl-universal

Internationalize React apps. Not only for Component but also for Vanilla JS.
1.33k stars 154 forks source link

fix: `importStar` or `importDefault` will both work #192

Closed Cecil0o0 closed 2 years ago

Cecil0o0 commented 2 years ago

There are plenty of developers who use old fashioned style to import this library, which is not totally compatible with ECMAScript Module System. Just like React, which is a pure CommonJS library too.

'importStar' or 'importDefault' will both work in any bundler with CommonJS Module System and ECMAScript Module System, for example vite, esbuild, webpack, or some frameworks on them, just like rollup, umijs, parcel and so on.

import * as React from 'react';

// or

import React from 'react';

So does this pr do.

import * as intl from 'react-intl-universal';

// or

import intl from 'react-intl-universal';

and optimize grammar of best practice in README.md

cwtuan commented 2 years ago

Merged at https://github.com/alibaba/react-intl-universal/commit/ed016b961e1c34cb8c83e1b16e8427091428302c