Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🙋 Aliasing modules -- react -> preact-compat etc. #832

Closed
fu5ha opened this issue Feb 16, 2018 · 3 comments · Fixed by #850
Closed

🙋 Aliasing modules -- react -> preact-compat etc. #832

fu5ha opened this issue Feb 16, 2018 · 3 comments · Fixed by #850

Comments

@fu5ha
Copy link
Contributor

fu5ha commented Feb 16, 2018

It is impossible to use parcel with preact-compat because it requires being able to alias all references to 'react' and 'react-dom' to 'preact-compat'. It is possible to do this for local package using browser in package.json, but does not work when including external React components.

🤔 Expected Behavior

Add an alias field in, say, package.json, like

"alias": {
    "^react$": "preact-compat",
    "react-dom$": "preact-compat",
    "react-dom/server": "preact-compat/server"
}

Which would then replace all references to react with preact-compat etc.

😯 Current Behavior

Using browser field, I can replace local import/requires successfully, but when importing, say react-apollo, it doesn't replace there.

🔦 Context

I know there was an issue #25 for this but it got locked and I haven't seen any further discussion about it, but this is quite inconvenient for people trying to use preact. I think it was a bad decision to completely delete all discussion about current workarounds as now people have no reference on what to do until this gets implemented natively.

Workaround for now

The workaround I found is to make symbolic links in the node_modules folder so that node_modules/react and node_modules/react-dom both link to node_modules/preact-compat.

@Nantris
Copy link

Nantris commented Feb 18, 2018

Would really love this. Parcel is very cool, but I've kind of screwed myself out of its use in the short term by using Webpack's aliasing so much.

@devongovett
Copy link
Member

See #850 for an implementation of aliases as part of our new resolver.

@ckken
Copy link

ckken commented Feb 28, 2018

no work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants