After haul upgrade can't compile with TypeError: compilation.getAsset is not a function
- Dominant language
- TypeScript
- Stars
- 3.7k
- Forks
- 185
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
```
"@haul-bundler/babel-preset-react-native": "^0.13.2",
"@haul-bundler/cli": "^0.13.1",
"@haul-bundler/inspector": "^0.13.0",
"@haul-bundler/preset-0.60": "^0.13.0",
"react-native": "^0.61.1",
Node v10.16.0
```
Config:
```
// since preset-0.61 isn't yet available
import { withPolyfills, makeConfig } from '@haul-bundler/preset-0.60';
const removeRuleByTest = (moduleConfig, test) => {
const index = moduleConfig.findIndex(rule => {
if (rule.test) {
return rule.test.toString() === test.toString();
}
return false;
});
moduleConfig.splice(index, 1);
};
export default makeConfig({
bundles: {
index: platform => ({
entry: withPolyfills(`./src/index.${platform}.js`),
transform({ config }) {
// Remove babel-loader, as it handles both .ts(x) and .js(x) files
removeRuleByTest(config.module.rules, /\.[jt]sx?$/);
config.module.rules = [
{
exclude: /node_modules(?!.*[\/\\](react|@react-native-community|@haul-bundler))/,
test: /\.tsx?$/,
loader: 'ts-loader',
},
...config.module.rules,
// Re-add the babel-loader, now only for .js(x)
{
exclude: /node_modules(?!.*[\/\\](react|@react-native-community|@haul-bundler))/,
test: /\.jsx?$/,
loader: require.resolve('babel-loader'),
options: {
plugins: [require.resolve('@haul-bundler/core/build/utils/fixRequireIssues')],
},
},
...config.module.rules,
];
config.resolve.extensions = [
`.${platform}.ts`,
'.mobile.ts',
'.native.ts',
`.${platform}.tsx`,
'.mobile.tsx',
'.native.tsx',
'.ts',
'.tsx',
...config.resolve.extensions,
];
},
}),
},
});
```
## Description
After upgrading to the new haul bundle from a working legacy instance and starting with a fresh config I seemingly can't exclude things from Typescript checks and compilation terminates. Not sure what I'm missing or am I looking at an outdated config?
```
Traviss-MacBook-Pro:xc **$ yarn ios --haul-inspector
yarn run v1.16.0
$ NODE_OPTIONS=--max_old_space_size=8192 REACT_NATIVE=true NODE_ENV=development yarn haul start --platform ios --eager ios --haul-inspector
[Logs]
done ▶︎ Packager server running on http://localhost:8081
error ▶︎ /Users/**/**/xc/node_modules/@haul-bundler/core/node_modules/webpack/lib/SourceMapDevToolPlugin.js:179
const asset = compilation.getAsset(file).source;
TypeError: compilation.getAsset is not a function
at files.forEach (/Users/**/**/xc/node_modules/@haul-bundler/core/node_modules/webpack/lib/SourceMapDevToolPlugin.js:179:33)
at Array.forEach ()
at compilation.hooks.afterOptimizeChunkAssets.tap (/Users/**/**/xc/node_modules/@haul-bundler/core/node_modules/webpack/lib/SourceMapDevToolPlugin.js:178:12)
at SyncHook.eval [as call] (eval at create (/Users/**/**/xc/node_modules/tapable/lib/HookCodeFactory.js:19:10), :12:1)
at SyncHook.lazyCompileHook (/Users/**/**/xc/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeChunkAssets.callAsync.err (/Users/**/**/xc/node_modules/webpack/lib/Compilation.js:1313:42)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/**/**/xc/node_modules/tapable/lib/HookCodeFactory.js:32:10), :9:1)
at AsyncSeriesHook.lazyCompileHook (/Users/**/**/xc/node_modules/tapable/lib/Hook.js:154:20)
at hooks.additionalAssets.callAsync.err (/Users/**/**/xc/node_modules/webpack/lib/Compilation.js:1309:36)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/**/**/xc/node_modules/tapable/lib/HookCodeFactory.js:32:10), :9:1)
at AsyncSeriesHook.lazyCompileHook (/Users/**/**/xc/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeTree.callAsync.err (/Users/**/**/xc/node_modules/webpack/lib/Compilation.js:1305:32)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/**/**/xc/node_modules/tapable/lib/HookCodeFactory.js:32:10), :9:1)
at AsyncSeriesHook.lazyCompileHook (/Users/**/**/xc/node_modules/tapable/lib/Hook.js:154:20)
at Compilation.seal (/Users/**/**/xc/node_modules/webpack/lib/Compilation.js:1242:27)
at hooks.make.callAsync.err (/Users/**/**/xc/node_modules/webpack/lib/Compiler.js:546:17)
at _err0 (eval at create (/Users/**/**/xc/node_modules/tapable/lib/HookCodeFactory.js:32:10), :11:1)
at _addModuleChain (/Users/**/**/xc/node_modules/webpack/lib/Compilation.js:1093:12)
at processModuleDependencies.err (/Users/**/**/xc/node_modules/webpack/lib/Compilation.js:1005:9)
at process._tickCallback (internal/process/next_tick.js:61:11)
```
## Reproducible Demo
Contributor guide
Assessment
This issue has not been assessed yet.