-
-
Notifications
You must be signed in to change notification settings - Fork 19
Description
🐛 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 :
To Reproduce
- Create a project in NPM and add Parcel as bundler
- Install i18nextify as an npm module (
npm i i18nextify) - 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>
- Install namer plugin for Parcel to preserve directory structure. Additionally,
.parcelrcin 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"]
}
}
- 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, tryingnpm run buildtriggers 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
