i18next / i18next-browser-languageDetector

language detector used in browser environment for i18next
MIT License
873 stars 90 forks source link

Rollup | Legacy | Error: 'default' is not exported #189

Closed tugend closed 5 years ago

tugend commented 5 years ago

All other packages I currently use, works fine. But for i18next-browser-languageDetector I get this error. Any ideas for solving it would be very welcome. ^_^

by node_modules\i18next-browser-languagedetector\index.js

import XHR from 'i18next-xhr-backend'
import LanguageDetector from 'i18next-browser-languagedetector';
          ^
const languageDetectorConfig = {
Error: 'default' is not exported by node_modules\i18next-browser-languagedetector\index.js
    at error (...\node_modules\rollup\dist\rollup.js:10151:30)

My setup is rollup with babel and looks like this.

[
    {
        "input": "index.html",
        "treeshake": true,
        "output": {
            "dir": "..\\wwwroot\\legacy",
            "format": "system",
            "sourcemap": true,
            "dynamicImportFunction": false
        },
        "plugins": [
            { "name": "index-html" },
            { "name": "node-resolve" },
            { "name": "babel" },
            { "name": "terser" },
            { "name": "copy" }
        ]
    },
    {
        "input": "index.html",
        "treeshake": true,
        "output": {
            "dir": "..\\wwwroot",
            "format": "esm",
            "sourcemap": true,
            "dynamicImportFunction": "importShim"
        },
        "plugins": [
            { "name": "index-html" },
            { "name": "node-resolve" },
            { "name": "babel" },
            { "name": "terser" },
            { "name": "copy" }
        ]
    }
]

and my .babelrc looks like this.

{
    "presets": [
        "@babel/preset-typescript"
    ],
    "plugins": [
        ["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }],
        "@babel/plugin-proposal-class-properties"
    ]
}
jamuhl commented 5 years ago

I personally do avoid configuration of webpack/rollbar/... just too many options and complexity...if there needs something to be changed here a PR would be welcome...hopefully someone out of the community can be of more help...

tugend commented 5 years ago

I think it's because it's wrapped in an export that diverges from the usual, like they do in i18next for example. It works fine if I do this explicitly instead import LanguageDetector from 'i18next-browser-languagedetector/dist/es/index.js';

jamuhl commented 5 years ago

Sorry I somehow missed to see your reply...looks like i18next and some other plugins where updated to newer configuration, this one lacks behind...will see what I can do the next days or merge a PR if you like to provide the update.

jamuhl commented 5 years ago

tried to update to be in line with other plugins like the xhr backend...

can you please retry with i18next-browser-languagedetector@4.0.0

tugend commented 5 years ago

Works. Thanks. ^_^

tugend commented 5 years ago

Nice work.

jamuhl commented 5 years ago

Thanks for reporting back...👍

If you like this module don’t forget to star this repo. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project -> there are many ways to help this project :pray: