exceljs / exceljs/exceljs

[Q] usage with TypeScript and webpack 5 (CRA 5.0.1)

Open
#2,639 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
15.5k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

We had exceljs working with our old webpack/CRA v4 setup that looked like this:

```
// tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"lib": ["dom", "dom.iterable", "esnext", "webworker"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"outDir": "./built",
"typeRoots": ["./typings", "./node_modules/@types"]
},
"include": ["**/*", "typings"],
"paths": [
{
"exceljs": "node_modules/exceljs/dist/exceljs.bare.min.js"
}
]
}
```

```
// craco.config.js
module.exports = {
devServer: () => {
// ...
},
webpack: {
configure: (webpackConfig) => {
// ...
webpackConfig.resolve.alias.exceljs = 'exceljs/dist/exceljs.bare.min.js';
return webpackConfig;
},
};
```

After updating CRA to 5.0.1 we now get an error saying:

```
ReferenceError: process is not defined
at Readable.on (_stream_readable.js:763:1)
at createReadableStreamAsyncIterator (async_iterator.js:177:1)
at Readable. (_stream_readable.js:922:1)
at M.read (xlsx.js:251:1)
at parseXLSX (excel.ts:313:1)
at async submitMetadata (foo.tsx:151:1)
```

Do we need to change anything with the setup? How do we get this working with webpack 5?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.