napi-rs / napi-rs/node-rs

node-rs/bcrypt: RollupError: Unexpected character '\u{7f}'

Open
#816 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.5k
Forks
52
Avg merge
13h 37m
Merged PRs (30d)
19

Description

I'm having issue during building a SvelteKit project with napi-rs/node-rs. The issue occurs when building it in Docker image but when I build it on Vercel it's working.

I tried to use vite.config.ts from use-napi-rs-packages-with-bundlers but I'm only getting another error (SvelteKit can't use webpack).

✓ built in 15.37s

> Using @sveltejs/adapter-node
error during build:
RollupError: Unexpected character '\u{7f}'
     at getRollupError (file:///app/node_modules/.pnpm/rollup@4.13.2/node_modules/rollup/dist/es/shared/parseAst.js:376:41)
     at ParseError.initialise (file:///app/node_modules/.pnpm/rollup@4.13.2/node_modules/rollup/dist/es/shared/node-entry.js:11175:28)
     at convertNode (file:///app/node_modules/.pnpm/rollup@4.13.2/node_modules/rollup/dist/es/shared/node-entry.js:12915:10)
     at convertProgram (file:///app/node_modules/.pnpm/rollup@4.13.2/node_modules/rollup/dist/es/shared/node-entry.js:12235:12)
     at Module.setSource (file:///app/node_modules/.pnpm/rollup@4.13.2/node_modules/rollup/dist/es/shared/node-entry.js:14074:24)
     at async ModuleLoader.addModuleSource (file:///app/node_modules/.pnpm/rollup@4.13.2/node_modules/rollup/dist/es/shared/node-entry.js:18713:13)
------
Dockerfile:12
--------------------
  10 |     ENV NODE_ENV=production
  11 |     ENV IS_DOCKER=true
  12 | >>> RUN npm run build
  13 |
  14 |     FROM node:18.20.0-alpine3.19
--------------------
ERROR: failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

I'm using @sveltejs/kit@^2.5.5, @node-rs/bcrypt@^1.10.1 and vite@^5.2.7. This error occurs in another dockerized SvelteKit projects aswell.

"devDependencies": {
	"@internationalized/date": "^3.5.2",
	"@melt-ui/pp": "^0.3.0",
	"@melt-ui/svelte": "^0.74.4",
	"@node-rs/bcrypt": "^1.10.1",
	"@prgm/sveltekit-progress-bar": "^2.0.0",
	"@sveltejs/adapter-auto": "^3.2.0",
	"@sveltejs/adapter-node": "^5.0.1",
	"@sveltejs/adapter-vercel": "^5.2.0",
	"@sveltejs/kit": "^2.5.5",
	"@sveltejs/vite-plugin-svelte": "^3.0.2",
	"@tanstack/query-persist-client-core": "^5.28.9",
	"@tanstack/query-sync-storage-persister": "^5.28.9",
	"@tanstack/react-query-persist-client": "^5.28.9",
	"@tanstack/svelte-query": "^5.28.9",
	"@tanstack/svelte-query-devtools": "^5.28.10",
	"@typegoose/auto-increment": "^4.2.0",
	"@types/bcrypt": "^5.0.2",
	"@types/crypto-js": "^4.2.2",
	"@types/js-cookie": "^3.0.6",
	"@types/mongoose-auto-increment": "^5.0.38",
	"@types/mongoose-sequence": "^3.0.11",
	"@types/uuid": "^9.0.8",
	"@vitejs/plugin-react": "^4.2.1",
	"axios": "^1.6.8",
	"crypto-js": "^4.2.0",
	"jose": "^5.2.3",
	"js-cookie": "^3.0.5",
	"mongoose": "^8.2.4",
	"mongoose-auto-increment": "^5.0.1",
	"mongoose-paginate-v2": "^1.8.0",
	"mongoose-sequence": "^6.0.1",
	"rollup-plugin-typescript2": "^0.36.0",
	"sass": "^1.72.0",
	"svelte": "^4.2.12",
	"svelte-check": "^3.6.8",
	"swrv": "^1.0.4",
	"ts-node": "^10.9.2",
	"ts-patch": "^3.1.2",
	"tslib": "^2.6.2",
	"typescript": "^5.4.3",
	"uuid": "^9.0.1",
	"vite": "^5.2.7"
},

My Dockerfile is:

FROM node:18.20.0-alpine3.19 AS builder

RUN npm install -g pnpm

WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm i

COPY . .
ENV NODE_ENV=production
ENV IS_DOCKER=true
RUN npm run build

FROM node:18.20.0-alpine3.19
WORKDIR /app
COPY --from=builder /app/build build/
COPY package.json .
EXPOSE 3000
CMD ["node", "build"]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure from the provided Dockerfile with package.json and pnpm-lock.yaml, then compare the Docker build with the working Vercel build. Trace how @node-rs/bcrypt is handled during the SvelteKit/Vite/Rollup build; done means identifying a reproducible compatibility cause and documenting or fixing the Docker build without the Rollup parse error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, nodejs, rollup, rust, vite
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.