repack
repack copied to clipboard
Cannot load local chunks: cannot read property loadScript of undefined
Environment
React Native 0.69.5
Description
Since upgrading to 3.0, the ScriptManager seems to fail to load scripts with the error of "cannot read property loadScript of undefined"
Reproducible Demo
Here's my scriptManager
ScriptManager.shared.setStorage(AsyncStorage);
ScriptManager.shared.addResolver(async (scriptId, caller) => {
// In dev mode, resolve script location to dev server.
if (__DEV__) {
return {
url: Script.getDevServerURL(scriptId),
cache: false
};
}
// In production, get chunks matching the regex from filesystem.
if (/^.+\.remote$/.test(scriptId)) {
return {
url: Script.getRemoteURL(`https://my-domain.dev/${scriptId}`)
};
} else {
return {
url: Script.getFileSystemURL(scriptId)
};
}
});
And I'm using React.Lazy to import the file
const Screen = React.lazy(
() =>
import(/* webpackChunkName: "async_body" */ './Screen')
);
And this is the extraChunks in webpack config
extraChunks: [
{
include: /.*/,
type: 'local'
},
{
// IMPORTANT!
exclude: /^.+\.remote$/,
type: 'remote',
outputPath: path.join('build/output', platform, 'remote') // Default path
}
]