Skip to content

Improve Build Scripts for Contributors & Users #295

@lari-ks

Description

@lari-ks

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

jodit-react@5.0.13 build
npm run build:react && npm run build:types

jodit-react@5.0.13 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

jodit-react@5.0.13 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

jodit-react@5.0.13 build
npm run build:react && npm run build:types

jodit-react@5.0.13 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

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