ardatan / ardatan/meteor-webpack

Cannot read property 'getSourceHash' of undefined

Open
#23 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
123
Forks
28
PR merge metrics
No merged PRs in 30d

Description

Hi

When trying to make a production build using the following command
`WEBPACK_CONFIG_FILE=\"webpack.prod.js\" meteor build --architecture=os.linux.x86_64 --allow-superuser --directory .build`
I get the following error:

```
Errors prevented bundling:
While processing files with ardatan:webpack (for target web.browser):
packages/webpack_plugin.js:74:43: Cannot read property 'getSourceHash' of undefined (at Object.processFilesForTarget)

While processing files with ardatan:webpack (for target os.linux.x86_64):
packages/webpack_plugin.js:74:43: Cannot read property 'getSourceHash' of undefined (at Object.processFilesForTarget)
```

I assume its printing twice, one for each bundle, client/server

My webpack configs are pretty simple:

```javascript
// webpack.common.js
const meteorExternals = require('webpack-meteor-externals');
const path = require('path');
const TsConfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

module.exports = {
devtool: 'cheap-module-source-map',
resolve: {
extensions: ['.json', '.js', '.jsx', '.ts', '.tsx'],
alias: {
tests: path.resolve(__dirname, 'tests'),
'/imports': path.resolve(__dirname, 'imports'),
imports: path.resolve(__dirname, 'imports'),
},
plugins: [
new TsConfigPathsPlugin({
configFile: path.resolve(__dirname, 'tsconfig.json'),
}),
],
},
module: {
rules: [
{
test: /\.jsx?$/,
use: 'babel-loader?cacheDirectory',
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
externals: [meteorExternals()],
};
```

```javascript
// webpack.prod.js
const merge = require('webpack-merge');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');

const webpackCommon = require('./webpack.common');

const clientConfig = merge(webpackCommon, {
devtool: 'sourcemap',
entry: [path.resolve(__dirname, 'client', 'main')],
mode: 'production',
module: {
rules: [
{
test: /\.scss/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.css/,
use: ['style-loader', 'css-loader'],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './client/main.html',
}),
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
],
});

const serverConfig = merge(webpackCommon, {
devtool: 'sourcemap',
mode: 'production',
entry: path.resolve(__dirname, 'server'),
target: 'node',
});

module.exports = [clientConfig, serverConfig];

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with packages/webpack_plugin.js at line 74 and reproduce the production build using the reported meteor build command and webpack.prod.js configuration. Trace why getSourceHash is accessed on an undefined value for both web.browser and os.linux.x86_64 targets. Done means the build completes without either bundling error, with a regression test if the repository provides a suitable test location.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.