Fuse-box: Aliases are not applied to deep require() calls

Created on 23 Feb 2017  路  5Comments  路  Source: fuse-box/fuse-box

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

bug

All 5 comments

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 :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thepatrick picture thepatrick  路  5Comments

viankakrisna picture viankakrisna  路  5Comments

miickel picture miickel  路  4Comments

charles-mathieus-jomedia picture charles-mathieus-jomedia  路  4Comments

hilarycheng picture hilarycheng  路  3Comments