Git Product home page Git Product logo

Comments (10)

JohnRSim avatar JohnRSim commented on May 18, 2024 2

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.

JohnRSim avatar JohnRSim commented on May 18, 2024 1

atlasmobileportal-master (1).zip

Attached my source for review.

from svelte-i18n.

kaisermann avatar kaisermann commented on May 18, 2024 1

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.

JohnRSim avatar JohnRSim commented on May 18, 2024 1

Thanks @kaisermann all working now! :)

from svelte-i18n.

JohnRSim avatar JohnRSim commented on May 18, 2024

node v13.2.0

from svelte-i18n.

kaisermann avatar kaisermann commented on May 18, 2024

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.

JohnRSim avatar JohnRSim commented on May 18, 2024

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.

JohnRSim avatar JohnRSim commented on May 18, 2024

Also looking in _layout I see this message

image

from svelte-i18n.

kematzy avatar kematzy commented on May 18, 2024

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.

kaisermann avatar kaisermann commented on May 18, 2024

@JohnRSim Got some time to test your project! You're missing the init() call on server.js as well as setting the fallbackLocale!

  1. Add import './i18n.js' to your server.js
  2. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.