Closed thekevshow closed 7 months ago
There might be an easier way, but I think you have to map it to the browser distribution via alias
in the webpack config. Assuming you want to webpack it without also doing the browserification part as well.
via: https://github.com/LibertyDSNP/example-client/blob/main/config/webpack.config.js#L308-L316
webpack.config.js
return {
// ...
alias: {
"@dsnp/parquetjs": path.resolve(
__dirname,
"..",
"node_modules",
"@dsnp",
"parquetjs",
"dist",
"browser",
"parquet.cjs.js"
),
// ...
}
This still doesn't seem to work causing an error
TypeError: Cannot read properties of undefined (reading 'webkitRequestFileSystem')
@wilwade
Hmm..
Here is what the webpack config looks like
const path = require('path');
const libExternals = {
}
const streamWorkerPackage = {
entry: ['./packages/stream-workers/index.js'],
target: 'node',
output: {
path: `${process.cwd()}/bin/stream-workers`,
filename: 'index.js',
libraryTarget: 'umd'
},
resolve: {
symlinks: false,
extensions: ['.js', '.json'],
alias: {
"@dsnp/parquetjs": path.resolve(__dirname, 'node_modules', '@dsnp/parquetjs', 'dist', 'browser', 'parquet.cjs.js')
// "@dsnp/parquetjs": path.resolve(
// __dirname,
// "..",
// "node_modules",
// "@dsnp",
// "parquetjs",
// "dist",
// "browser",
// "parquet.cjs.js"
// ),
}
},
externals: {
...libExternals
}
}
module.exports = [
streamWorkerPackage
];
and I am using versions listed here:
"webpack": "5.90.1",
"webpack-cli": "5.1.4"
@thekevshow Hmm... Is this for a library or for a direct web application?
If it is a library, then I would suggest a different route to get a better build: Handle the shims directly. So Parquetjs takes a lot of node libraries to work. The browser edition is designed to be used directly in a script tag, or in some cases in a build where you know there are no need for the build to otherwise shim those node packages.
Might also help to get a trace for that TypeError: Cannot read properties...
error. This sounds like a Webkit issue and I am very out of date on my webkit.
This is not for a web application it is for an AWS lambda which we are webpacking to bundle everything into for cost saving and cold time reducing pieces here. For all intensive purposes it is a nodejs application. Testing was done locally with the webpack result. @wilwade but that makes sense appreciate it.
Steps to Reproduce
@dsnp/parquetjs
as a dependency.const { ParquetWriter } = require('@dsnp/parquetjs');
in the main file.Expected Behaviour
The application should bundle without errors and the
@dsnp/parquetjs
module should be correctly imported and functional when running the bundled code.Actual Behaviour
Upon running the Webpack bundle, the application throws an error:
Error: Cannot find module 'util'
. This suggests that Webpack is unable to resolve theutil
module, a core Node.js module, which is required by@dsnp/parquetjs
or its dependencies.Any Logs, Error Output, Etc.?
Any Other Comments?
util
in Webpack did not succeed.@dsnp/parquetjs
in a Webpack-bundled Node.js environment.