Git Product home page Git Product logo

Comments (7)

Romanchuk avatar Romanchuk commented on May 27, 2024

@httpete Hi, dont you miss I18NextModule.forRoot() method? Or may be you call translation methods before forRoot was called.
Also this article could help:
https://www.gurustop.net/blog/2017/02/14/shared-modules-in-angular-apps-providers-best-practices-and-what-does-forroot-do/

Did issue appear right after angular update?

from angular-i18next.

httpete avatar httpete commented on May 27, 2024

Hi, I found that my webpack config needed this in my resolve, the part about "mainFields" lit it up. I guess you use a different main field in package.json?

        resolve: {
            extensions: ['.ts', '.js'],
            modules: [
                "./node_modules",
                "./node_modules"
            ],
            symlinks: false,
            mainFields: [
                "browser",
                "module",
                "main"
            ],
            alias: {
                angular: path.resolve(path.join(__dirname, 'node_modules', 'angular')),
                lodash: path.resolve(path.join(__dirname, 'node_modules', 'lodash-amd')),
                jquery: "jquery/dist/jquery.slim.js"
            }
        },

from angular-i18next.

Romanchuk avatar Romanchuk commented on May 27, 2024

In angular-i18next package.json i use 'module'. This is proposal for nodejs.
https://stackoverflow.com/questions/42708484/what-is-the-module-package-json-field-for

May be i should also specify 'main' parameter because 'module' is not official part of package.json
https://docs.npmjs.com/files/package.json#main

Here is angular-i18next package.json

{
    "name": "angular-i18next",
    "version": "3.2.0",
    "homepage": "https://github.com/Romanchuk/angular-i18next#readme",
    "author": {
        "name": "Sergey Romanchuk"
    },
    "license": "MIT",
    "description": "i18next module for Angular",
    "repository": {
        "type": "git",
        "url": "git+https://github.com/Romanchuk/angular-i18next.git"
    },
    "keywords": [
        "i18n",
        "i18next",
        "angular"
    ],
    "bugs": {
        "url": "https://github.com/Romanchuk/angular-i18next/issues"
    },
    "maintainers": [{
        "email": "[email protected]",
        "name": "Sergey Romanchuk"
    }],
    "module": "angular-i18next.es5.js",
    "es2015": "angular-i18next.js",
    "typings": "angular-i18next.d.ts",
    "peerDependencies": {
        "@angular/common": ">=4.0.0 <6.0.0",
        "@angular/core": ">=4.0.0 <6.0.0",
        "@angular/platform-browser": ">=4.0.0 <6.0.0",
        "rxjs": "^5.5.2",
        "i18next": ">=8.4.0 <11.0.0"
    }
}

from angular-i18next.

httpete avatar httpete commented on May 27, 2024

from angular-i18next.

Romanchuk avatar Romanchuk commented on May 27, 2024

@httpete
I found great article about setting up packages.

It says:

Angular v4 delivers each package in three formats:

UMD: via property main
ES5/ESM: via property module
ES6/ESM: via property es2015

This is what its package.json looks like:

{
  "name": "@angular/core",
  "main": "./bundles/core.umd.js",
  "module": "./@angular/core.es5.js",
  "es2015": "./@angular/core.js",
  ···
}

I'm going to add "main" property with umd compiled module ASAP.

But anyway i still can't reproduce this issue using webpack (demo app) neither using angular-cli. I never used to set "mainFields" in resolvers. Webpack has defaults that are always include 'module' mainField

from angular-i18next.

Romanchuk avatar Romanchuk commented on May 27, 2024

@httpete just published 3.3.0-beta.1 version with 'main' prop setted to umd compiled file.
Please try it
npm install angular-i18next@beta --save

from angular-i18next.

httpete avatar httpete commented on May 27, 2024

Romanchuk, interestingly it didn't change anything, until I changed my tsconfig.json: this might have to do with the fact that I am running on file:../ links for local development of my shared library.

`{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "paths": {
      "@angular/*": [
        "../node_modules/@angular/*"
      ],
      "@ng-bootstrap/*": [
        "../node_modules/@ng-bootstrap/*"
      ],
      "@uirouter/*": [
        "../node_modules/@uirouter/*"
      ],
      "angular-i18next": [
        "../node_modules/angular-i18next"
      ]
    },
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

from angular-i18next.

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.