Comments (10)
if I run
npm run dev
works fine but when I run
npm run export
I now get this error:
> Built in 15.7s
> Crawling http://localhost:3000/
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:7275)
at Object.preload (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\app-46c76819.js:372:20)
at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2420:29)
at handle_error (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2308:3)
at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2472:5)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
32 B (500) index.html
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:7275)
at Object.preload (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\app-46c76819.js:372:20)
at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2420:29)
at handle_error (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2308:3)
at handle_page (C:\work\fishbowl\gitlab\atlasmobileportal\__sapper__\build\server\server.js:2472:5)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
32 B (500) service-worker-index.html
> Finished in 16.7s. Type npx serve __sapper__/export to run the app.
from svelte-i18n.
atlasmobileportal-master (1).zip
Attached my source for review.
from svelte-i18n.
I also just added a quick note to the wiki about having to add to the server.js
! And @kematzy solution to https://github.com/kaisermann/svelte-i18n/wiki/FAQ#this-keyword-is-equivalent-to-undefined
from svelte-i18n.
Thanks @kaisermann all working now! :)
from svelte-i18n.
node v13.2.0
from svelte-i18n.
Hey @JohnRSim 👋
The first issue, about the warnings, is a duplicate of #12. This is rollup being more cautious than it should for this specific case. Please read the aforementioned issue for more details about it 😁.
And for the second one, would you be able to share the rest of your svelte-i18n
configs or a repro? For what I can see from the log, you're maybe missing the init({})
call.
from svelte-i18n.
Hi Kaisermann
I've upgraded from
"svelte-i18n": "^2.1.1"
to
"svelte-i18n": "^2.2.0"
this morning and it appears to have fixed the issue.
from svelte-i18n.
Also looking in _layout I see this message
from svelte-i18n.
POSSIBLE SOLUTION:
I too experienced this repeated warning output in the CLI output until a few minutes ago:
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++) {
My "fix" is based upon Rich Harris' answer.
My rollup.config.js
file now contains the following:
const onwarn = (warning, onwarn) =>
(warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) ||
(warning.code === 'THIS_IS_UNDEFINED') || onwarn(warning);
The key part added was:
(warning.code === 'THIS_IS_UNDEFINED')
Now all those warnings are gone, but your mileage may vary.
For Reference Only:
I'm using a version of the mdauner/sapper-tailwindcss-template, with svelte-i18n
based upon the code from kaisermann/svelte-i18n example.
Key parts from my
package.json
"dependencies": {
"@fullhuman/postcss-purgecss": "^1.3.0",
"autoprefixer": "^9.7.0",
"compression": "^1.7.1",
"cssnano": "^4.1.10",
"polka": "next",
"postcss": "^7.0.21",
"postcss-import": "^12.0.1",
"postcss-url": "^8.0.0",
"purgecss-from-svelte": "^2.0.2",
"rollup-plugin-postcss": "^2.0.3",
"sirv": "^0.4.0",
"svelte-i18n": "^2.2.1",
"svelte-preprocess": "^3.1.4",
"tailwindcss": "^1.1.3"
},
"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.6.3",
"@babel/runtime": "^7.6.3",
"@rollup/plugin-json": "^4.0.1",
"cypress": "^3.8.1",
"npm-run-all": "^4.1.5",
"precss": "^4.0.0",
"rollup": "^1.26.0",
"rollup-plugin-babel": "^4.0.2",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-svelte": "^5.0.1",
"rollup-plugin-terser": "^5.1.2",
"sapper": "^0.27.0",
"svelte": "^3.0.0",
"svelte-image": "^0.1.9"
}
rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import replace from 'rollup-plugin-replace';
import commonjs from 'rollup-plugin-commonjs';
import svelte from 'rollup-plugin-svelte';
import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';
import config from 'sapper/config/rollup.js';
import json from '@rollup/plugin-json';
import pkg from './package.json';
import getPreprocessor from "svelte-preprocess";
import postcss from "rollup-plugin-postcss";
import PurgeSvelte from "purgecss-from-svelte";
import path from "path";
const mode = process.env.NODE_ENV;
const dev = mode === 'development';
const legacy = !!process.env.SAPPER_LEGACY_BUILD;
const onwarn = (warning, onwarn) =>
(warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) ||
(warning.code === 'THIS_IS_UNDEFINED') || onwarn(warning);
....
from svelte-i18n.
@JohnRSim Got some time to test your project! You're missing the init()
call on server.js
as well as setting the fallbackLocale
!
- Add
import './i18n.js'
to yourserver.js
- Uncomment the
fallbackLocale: 'en'
And it should be working again 😁
About the warning, you can do what @kematzy said 👍
from svelte-i18n.
Related Issues (20)
- Support Svelte 4 HOT 3
- Allow unit tests with ts-node esm HOT 1
- Sveltekit: Update translation outside of component
- Variable inside html isn't replaced HOT 1
- Inform about unused language keys HOT 1
- When I hover over a <a> the site language changes to the default language. HOT 1
- `intl-getcanocicallocales` is probably not a good idea HOT 2
- CJS / ESM conflict HOT 22
- Change log version comparison links are off
- Production build using svelte-i18n ^3.7.4 throws "Named export 'IntlMessageFormat' not found." HOT 6
- Problems with LIB check in cli extractor HOT 1
- Sapper reference in Getting Started guide
- Allow to restrict some parts of the i18n file to unauthorized users in SvelteKit. HOT 3
- Is it possible when registering several json files to overwrite the previous key contents with latest file?
- Docs on how to use variables in translation strings HOT 1
- How to disable AM/PM in $time formatter
- Leading zeros for day/month when formatting date values
- Add a register store?
- Build error when deploying in vercel
- Provide a Readable<string> instead of pure string
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-i18n.