preact-x + webpack + resolve preact/compat

Created on 5 Mar 2019  路  4Comments  路  Source: preactjs/preact

It looks like the [email protected] export is not being correctly aliased by Webpack with:

    resolve: {
        alias: {
            'react': 'preact/compact',
            'react-dom': 'preact/compact',
        },
    },

Webpack throws:
Module not found: Error: Can't resolve 'react' in <module>

Repro:

git clone [email protected]:damianobarbati/webapp-kit.git
yarn install
yarn build:dev:hot

Aliasing:
https://github.com/damianobarbati/webapp-kit/blob/master/config/webpack.config.js#L39

Am I missing something stupid?

invalid

Most helpful comment

It's preact/compat, not preact/compact. I sent you a PR.

TBH we've seen quite a few folks misspelling. Might be worth having a /compact alias that throws or something.

All 4 comments

It's preact/compat, not preact/compact. I sent you a PR.

TBH we've seen quite a few folks misspelling. Might be worth having a /compact alias that throws or something.

Ops! I actually tried both, the (correct) latter results in

Can't import the named export 'Component' from non EcmaScript module (only default export is available)

Solved with your suggestion here:
https://github.com/developit/preact/issues/1321#issuecomment-469522281

It's preact/compat, not preact/compact. I sent you a PR.

TBH we've seen quite a few folks misspelling. Might be worth having a /compact alias that throws or something.

Just FYI I miss spelled it.... It took me some time racking my head and then finally googling to this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matthewmueller picture matthewmueller  路  3Comments

skaraman picture skaraman  路  3Comments

mizchi picture mizchi  路  3Comments

marcosguti picture marcosguti  路  3Comments

rajaraodv picture rajaraodv  路  3Comments