For example, using aliases such as:
alias: {
'react': 'preact-compat',
'react-dom': 'preact-compat'
}
And then also importing react-redux:
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Provider, connect } from 'react-redux';
import { createStore } from 'redux';
// ... stuff to create 'store' and 'Main' here ...
ReactDOM.render((
<Provider store={store}>
<Main />
</Provider>
), document.body);
It works up to a point. preact-compat is indeed imported for react and react-dom in my code; however, a runtime error occurs: Uncaught Package was not found "react".
After analyzing the bundle, it appears that the react-redux package is importing react in several places. These imports should also be aliased.
A test project demonstrating the issue with fuse-box 1.3.121-preview.1 is available here: https://github.com/xdave/fuse-box-alias-test
BTW, I have verified that when manually replacing the three occurrences of 'react' with 'preact-compat' within the app.js bundle after building makes the app work.
To be fair, this app ends up working if I also alias react-redux to use preact-redux; however, I'm not sure it should be necessary.
@xdave I think I know what's happening. Aliases are limited to the current project ATM. We could change that... Optionally
[email protected] that one fixes it!
Confirmed. Thanks :)