'this' keyword is equivalent to 'undefined'
See original GitHub issueEnv “svelte-i18n”: “^2.1.1” “sapper”: “^0.27.0”, “svelte”: “^3.0.0”
Describe the bug Adding the following shows trail of debug logs within the console.
//i18n.js
import { register, init } from 'svelte-i18n';
Logs
console log
sapper dev
✔ server (1.8s) • client The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __extends = (this && this.__extends) || (function () { ^ 2: var extendStatics = function (d, b) { 3: extendStatics = Object.setPrototypeOf || The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __extends = (this && this.__extends) || (function () { ^ 2: var extendStatics = function (d, b) { 3: extendStatics = Object.setPrototypeOf || The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 12: }; 13: })(); 14: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 15: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 16: for (var r = Array(s), k = 0, i = 0; i < il; i++) The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 12: }; 13: })(); 14: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 15: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 16: for (var r = Array(s), k = 0, i = 0; i < il; i++) The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 4: See the accompanying LICENSE file for terms. 5: */ 6: var __assign = (this && this.__assign) || function () { ^ 7: __assign = Object.assign || function(t) { 8: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 4: See the accompanying LICENSE file for terms. 5: */ 6: var __assign = (this && this.__assign) || function () { ^ 7: __assign = Object.assign || function(t) { 8: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 4: See the accompanying LICENSE file for terms. 5: */ 6: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 7: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 8: for (var r = Array(s), k = 0, i = 0; i < il; i++) The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 4: See the accompanying LICENSE file for terms. 5: */ 6: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 7: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 8: for (var r = Array(s), k = 0, i = 0; i < il; i++) The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 7: // tslint:disable:no-consecutive-blank-lines 8: // tslint:disable:align 9: var __extends = (this && this.__extends) || (function () { ^ 10: var extendStatics = function (d, b) { 11: extendStatics = Object.setPrototypeOf || The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 7: // tslint:disable:no-consecutive-blank-lines 8: // tslint:disable:align 9: var __extends = (this && this.__extends) || (function () { ^ 10: var extendStatics = function (d, b) { 11: extendStatics = Object.setPrototypeOf || The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 20: }; 21: })(); 22: var __assign = (this && this.__assign) || function () { ^ 23: __assign = Object.assign || function(t) { 24: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 20: }; 21: })(); 22: var __assign = (this && this.__assign) || function () { ^ 23: __assign = Object.assign || function(t) { 24: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __assign = (this && this.__assign) || function () { ^ 2: __assign = Object.assign || function(t) { 3: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __assign = (this && this.__assign) || function () { ^ 2: __assign = Object.assign || function(t) { 3: for (var s, i = 1, n = arguments.length; i < n; i++) { The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 2: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 3: for (var r = Array(s), k = 0, i = 0; i < il; i++) The ‘this’ keyword is equivalent to ‘undefined’ at the top level of an ES module, and has been rewritten 1: var __spreadArrays = (this && this.__spreadArrays) || function () { ^ 2: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 3: for (var r = Array(s), k = 0, i = 0; i < il; i++) ✔ service worker (27ms)
Listening on http://localhost:3000
When accessing localhost in a browser after adding the following to _layout.svelte
<script context="module">
import { waitLocale } from 'svelte-i18n';
export async function preload() {
// awaits for the loading of the 'en-US' and 'en' dictionaries
return waitLocale();
}
</script>
I get the following error within the console and the page no longer loads.
console log
TypeError: Cannot read property ‘split’ of null at getRelatedLocalesOf (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:4108) at hasLocaleQueue (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:2934) at flush (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:3039) at Object.waitLocale (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:7256) at Object.preload (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\user-35f39f10.js:348:20) at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2410:29) at handle_error (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2298:3) at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2462:5) at processTicksAndRejections (internal/process/task_queues.js:93:5) TypeError: Cannot read property ‘split’ of null at getRelatedLocalesOf (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:4108) at hasLocaleQueue (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:2934) at flush (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:3039) at Object.waitLocale (C:\work\fishbowl\gitlab\atlasmobileportal\node_modules\svelte-i18n\dist\i18n.js:15:7256) at Object.preload (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\user-35f39f10.js:348:20) at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2410:29) at handle_error (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2298:3) at Array.find_route (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2614:3) at nth_handler (C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2731:14) at C:\work\fishbowl\gitlab\atlasmobileportal_sapper_\dev\server\server.js:2731:31
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (3 by maintainers)
Top GitHub Comments
if I run
works fine but when I run
I now get this error:
Thanks @kaisermann all working now! 😃