bobbai00 commented on issue #4461:
URL: https://github.com/apache/texera/issues/4461#issuecomment-4300259572

   ## Proposed fix
   
   Texera's own source never references `jschardet` (verified with `grep -r 
jschardet frontend/src` — no matches). The package is pulled in by 
`@codingame/monaco-vscode-api` and shipped to the production bundle only 
because webpack resolves the import from Monaco's code paths. Since those code 
paths are not exercised by Texera's editor integration, we can replace 
`jschardet` with a tiny no-op stub at bundle time and the package will stop 
appearing in the shipped bundle (and therefore in `3rdpartylicenses.txt` and 
`LICENSE-binary`).
   
   ### Suggested change
   
   1. Add a stub at `frontend/stubs/jschardet.js`:
   
   ```js
   // jschardet is LGPL-2.1 and pulled in transitively by 
@codingame/monaco-vscode-api.
   // Texera never calls it, so bundle-time aliasing replaces it with a no-op 
to keep
   // LGPL code out of the shipped binary distribution.
   module.exports = {
     detect: () => ({ encoding: "UTF-8", confidence: 1 }),
     detectAll: () => [{ encoding: "UTF-8", confidence: 1 }],
   };
   ```
   
   2. Extend the existing `frontend/custom-webpack.config.js` with a 
`resolve.alias` entry:
   
   ```js
   module.exports = {
     module: { /* ...existing rules... */ },
     resolve: {
       alias: {
         jschardet: require("path").resolve(__dirname, "stubs/jschardet.js"),
       },
     },
   };
   ```
   
   ### Verification
   
   After the change:
   
   1. `yarn --cwd frontend run build` completes.
   2. `grep -n jschardet frontend/dist/3rdpartylicenses.txt` returns no matches 
(confirming it is no longer bundled).
   3. The `jschardet` entry can be removed from `LICENSE-binary`'s ASF Category 
X section once the content PR lands.
   
   ### Alternatives considered
   
   - **`yarn patch @codingame/monaco-vscode-api`** to delete jschardet imports 
upstream. More invasive; harder to maintain across upstream updates.
   - **Replace `@codingame/monaco-vscode-api`** with plain `monaco-editor`. 
Would lose VS Code API extensions that Texera's editor depends on.
   - **Yarn `resolutions` → portal: stub package**. Cleaner at install time, 
but finicky across CI environments.
   
   The webpack-alias approach has the smallest diff, touches only files Texera 
already maintains, and keeps the LGPL code strictly out of the shipped artifact.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to