Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Build Scripts for Contributors & Users #295

Open
lari-ks opened this issue Jan 28, 2025 · 0 comments · May be fixed by #296
Open

Improve Build Scripts for Contributors & Users #295

lari-ks opened this issue Jan 28, 2025 · 0 comments · May be fixed by #296

Comments

@lari-ks
Copy link

lari-ks commented Jan 28, 2025

Unable to run repo on a Windows or other OS.

Use Case for Proposal

I recently ran into an issue i wanted to take time to debug because i really wanted to use jodit in my Next.js project and i wanted to check if the demo could reproduce the same issue outside of Next or if it would be easier to debug with the repo locally - so this is why this is a problem if the repo cannot be run in different environments. These fixes allowed me to run and find the issue and open PR for it as well as these build fixes.

Opening this issue to link to PR.

The PR fixes 3 issues listed below with desscriptions of the type of errors they throw in another environment i.e. Windows
These issues prevent the contributor or user from running any of these scripts (or the demo ones but thats split out to a different PR)
npm run build
npm run build:types
npm run remove-css

  1. Using NODE_ENV instead of cross-env NODE_ENV is OS incompatible. cross-env makes it OS compatible which is good for a project that benefits from many contributors

$ npm run build

[email protected] build
npm run build:react && npm run build:types

[email protected] build:react
NODE_ENV=production node -r @swc-node/register ./node_modules/.bin/webpack --mode production

'NODE_ENV' is not recognized as an internal or external command,
operable program or batch file.

  1. Running npm run build:types broken
    Threw an error due to issue with remove-css - this is a simple fix in package.json
    Also could not build due to "skipLibCheck": true missing in tsconfig.types.json - threw errors about every .d.ts file, recommended to set to true so will be able to run build

[email protected] remove-css
replace "import '[^']+.css';" '' ./build/**/*.ts

node:fs:1633
const stats = binding.lstat(
^

Error: ENOENT: no such file or directory, lstat 'C:\Users\user\jodit-react\build**.ts'
at Object.lstatSync (node:fs:1633:25)
at replacizeFileSync (C:\Users\user\jodit-react\node_modules\replace\replace.js:140:22)
at module.exports (C:\Users\user\jodit-react\node_modules\replace\replace.js:80:17)
at Object. (C:\Users\user\jodit-react\node_modules\replace\bin\replace.js:42:1)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
errno: -4058,
code: 'ENOENT',
syscall: 'lstat',
path: 'C:\Users\user\jodit-react\build\**\
.ts'
}

  1. Running npm run build broken (below)
    This is what happens when using this ./node_modules/.bin/webpack in Windows env (below)
    Fixed by updating webpack.config to .js and package.json (adding webpack script that allows webpack to run correctly in any environment)
    This allows npm run build:types and npm run build runs successfully.

$ npm run build

[email protected] build
npm run build:react && npm run build:types

[email protected] build:react
cross-env NODE_ENV=production node -r @swc-node/register ./node_modules/.bin/webpack --mode production

C:\Users\user\jodit-react\node_modules.bin\webpack:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\,/,g')")
^^^^^^^

SyntaxError: missing ) after argument list
at wrapSafe (node:internal/modules/cjs/loader:1281:20)
at Module._compile (node:internal/modules/cjs/loader:1321:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Object.newLoader [as .js] (C:\Users\user\jodit-react\node_modules\pirates\lib\index.js:121:7)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49

Node.js v20.13.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant