intl-messageformat throwing warnings
See original GitHub issueI’m currently building a small app using the basic rollup svelte template, and svelte-i18n, and rollup is currently throwing the following warning when I build with locale or dictionary imported.
rollup v1.23.1
bundles src/main.js → public\bundle.js...
LiveReload enabled
(!) `this` has been rewritten to `undefined`
https://rollupjs.org/guide/en/#error-this-is-undefined
node_modules\intl-messageformat\lib\core.js
4: See the accompanying LICENSE file for terms.
5: */
6: var __extends = (this && this.__extends) || (function () {
^
7: var extendStatics = function (d, b) {
8: extendStatics = Object.setPrototypeOf ||
...and 3 other occurrences
node_modules\intl-messageformat\lib\compiler.js
4: See the accompanying LICENSE file for terms.
5: */
6: var __extends = (this && this.__extends) || (function () {
^
7: var extendStatics = function (d, b) {
8: extendStatics = Object.setPrototypeOf ||
...and 1 other occurrence
My package.json
{
"name": "svelte-app",
"version": "1.0.0",
"devDependencies": {
"npm-run-all": "^4.1.5",
"rollup": "^1.23.0",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-svelte": "^5.1.0",
"rollup-plugin-terser": "^5.1.2",
"svelte": "^3.12.0"
},
"dependencies": {
"date-fns": "^2.4.1",
"lodash": "^4.17.15",
"sirv-cli": "^0.4.4",
"svelte-i18n": "^1.1.2-beta",
"svelte-routing": "^1.4.0"
},
"scripts": {
"build": "rollup -c",
"autobuild": "rollup -c -w",
"dev": "run-p start:dev autobuild",
"start": "sirv public --single",
"start:dev": "sirv public --single --dev"
}
}
Anyone have any insights here?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Intl MessageFormat | Format.JS
Intl MessageFormat. Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.
Read more >intl-messageformat - npm
Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.. Latest version: 10.2.5, ...
Read more >format-message - npm Package Health Analysis - Snyk
Internationalize text, numbers, and dates using ICU Message Format For more information about how to use this package see README.
Read more >intl | Dart Package - Pub.dev
Contains code to deal with internationalized/localized messages, date and number formatting and parsing, bi-directional text, and other internationalization ...
Read more >formatjs - Bountysource
intl -messageformat-parser: Unable to import with latest node.js and ESM enabled. ... warning: warning Reading source file from TTY. and the process hangs, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh, and there may be a related issue in the intl-messageformat repo. It seems that the
var __extends = (this && this.__extends) || (function () {
code is created by TypeScript, which is the language intl-messageformat is written in, I believe. Not 100% sure about this but wanted to share in case someone wants to do a bit more digging.Hello @Sureiya. Yeah this seems to be a known issue with Rollup. To be consistent with native module implementations, Rollup sets
this = undefined
at the top level in modules. It also displays a warning if a module tries to usethis
at the top level. intl-messageformat has code that usesthis
at the top level, which upsets Rollup.The intl-messageformat code seems to work just fine, however, and I’ve gotten rid of the warnings by using the suggestion in the Rollup documentation to provide the two culprit modules—
node_modules\intl-messageformat\lib\core.js
andnode_modules\intl-messageformat\lib\compiler.js
—withwindow
instead ofundefined
as thethis
value. Since all our code runs in the browser, I’m assuming the two modules expectthis = window
. I’ve achieve the override in myrollup.config.js
:May be this should be addressed in the README doc? Happy to provide a PR if people agree.