Skip to content

Parcel reports a missing dependency while building a site with i18nextify #91

@Kilkenni

Description

@Kilkenni

🐛 Bug Report

I am building a static site with Parcel as bundler. It uses its own development server to serve and hot-reload pages.

I've added
<script src="/node_modules/i18nextify/i18nextify.min.js" type="module" id="i18nextify" fallbacklng="en"></script>
in <head> of my html file and created a translation.json, so i18nextify properly runs with ?debug=true.

However, building the site fails, as Parcel points out that the dependency "cross-fetch" that i18nextify uses is missing in its package.json :

Flameshot_2023-02-15_21-42-11

To Reproduce

  1. Create a project in NPM and add Parcel as bundler
  2. Install i18nextify as an npm module (npm i i18nextify)
  3. Configure scripts for Parcel in package.json like this:
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "rm -rf dist/* && parcel src/*.html src/locales/*/*",
    "build": "rm -rf dist/* && parcel build src/*.html scr/locales/*/*"
  }

What I'm doing here is processing all html files via parcel as well as any files in locales/*/ path - i.e. all the i18nextify translation files. My main file to serve is /src/index.html
4. Add i18nextify in the head of /src/index.html as the guide suggests:

<script src="/node_modules/i18nextify/i18nextify.min.js" type="module" id="i18nextify" fallbacklng="en"></script>
  1. Install namer plugin for Parcel to preserve directory structure. Additionally, .parcelrc in root directory of the project needs another option to skip bundling JSONs and copy them verbatim, so it should look like this in the end:
{
	"extends": "@parcel/config-default",
	"namers": ["@mischnic/parcel-namer-preserve-structure", "..."],
  "transformers": {
    "*.json": ["@parcel/transformer-raw"]
  }
}
  1. At this point if we launch dev version via npm run dev, Parcel serves the page with i18nextify working in it (with ?debug=true, of course). However, trying npm run build triggers this error.

Expected behavior

I expect the production version to be built and work just like the dev one does.

Your Environment

  • runtime version: Parcel 2.8.3, Firefox 110 64x
  • i18nextify version: 3.2.3
  • os: Ubuntu 22.01.1 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions