globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 605 forks source link

Readme example fail #813

Closed ButuzGOL closed 6 years ago

ButuzGOL commented 6 years ago

I wanted to test readme example but got issue

npm install globalize cldr-data iana-tz-data
var Globalize = require( "globalize" );
Globalize.load( require( "cldr-data" ).entireSupplemental() );
Globalize.load( require( "cldr-data" ).entireMainFor( "en", "es" ) );
Globalize.loadTimeZone( require( "iana-tz-data" ) );

Globalize("en").formatDate(new Date());
// > "11/27/2015"

Globalize("es").formatDate(new Date());
// > "27/11/2015"

<--- Last few GCs --->

[97121:0x102800600] 219576 ms: Mark-sweep 1406.0 (1517.3) -> 1406.0 (1517.3) MB, 3371.5 / 0.0 ms allocation failure GC in old space requested [97121:0x102800600] 222245 ms: Mark-sweep 1406.0 (1517.3) -> 1406.0 (1497.8) MB, 2668.6 / 0.0 ms last resort GC in old space requested [97121:0x102800600] 225459 ms: Mark-sweep 1406.0 (1497.8) -> 1405.9 (1497.8) MB, 3212.4 / 0.0 ms last resort GC in old space requested

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

rxaviers commented 6 years ago

I don't get the same issue. Can you provide additional information such as operating system, node and npm version.

ButuzGOL commented 6 years ago
➜  ~ node -v
v8.9.1
➜  ~ npm -v
5.5.1

Using with webpack

rxaviers commented 6 years ago

Can you create a gist with a reduced code that reproduces this problem please? Did you have issues installing cldr-data (i.e., https://github.com/rxaviers/cldr-data-npm/issues/49)?

ButuzGOL commented 6 years ago

Code

var Globalize = require( "globalize" );
Globalize.load( require( "cldr-data" ).entireSupplemental() );
Globalize.load( require( "cldr-data" ).entireMainFor( "en", "pt" ) );

var en = new Globalize( "en" );

// You can optionally omit the `new` operator.
var pt = Globalize( "pt" );

console.log(en.formatNumber( 3.1415 ));
// > 3.142

console.log(pt.formatNumber( 3.1415 ));
new GlobalizePlugin({
  production: false,
  developmentLocale: "en",
  supportedLocales: ["en", "pt", "es"],
})
"cldr-data": ">=25",
"globalize": "^1.3.0",
"globalize-webpack-plugin": "0.4.x",
"iana-tz-data": "^2017.1.0",
xehpuk commented 6 years ago

Same problem here. node@9.9.0 and npm@5.6.0.

https://github.com/rxaviers/cldr-data-npm/issues/55

rxaviers commented 6 years ago

When using globalize webpack plugin, one isn't supposed to use cldr-data.

Closing this in favor of https://github.com/rxaviers/cldr-data-npm/issues/55