Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Add .web.js and .web.jsx to resolve extension #1056

Closed
piu130 opened this issue Aug 29, 2018 · 4 comments · Fixed by #1064
Closed

Add .web.js and .web.jsx to resolve extension #1056

piu130 opened this issue Aug 29, 2018 · 4 comments · Fixed by #1064
Labels
Milestone

Comments

@piu130
Copy link
Contributor

piu130 commented Aug 29, 2018

Feature request or enhancement

We have some react-native-web support here in the react-preset.
For multi-platform support react-native-web need .web.js{x} files to be loaded like .android.js and .ios.js files. See here.
We should add those extensions somewhere in a preset or middleware (neutrino.config.resolve.extensions).

@edmorley
Copy link
Member

That makes sense - thank you for filing :-)

Presumably the @neutrinojs/react preset would need to:

  neutrino.config
    .resolve
      .extensions
        .merge(['.web.js', '.web.jsx']);

(That is presuming the order of resolve.extensions doesn't matter?)

@piu130
Copy link
Contributor Author

piu130 commented Aug 31, 2018

The order does matter:

// sayHello/index.js
export default () => console.log('hello')
// sayHello/index.web.js
export default () => console.log('hello web')
// index.js
import sayHello from './sayHello'
sayHello()

index.js logs hello if the extensions are added and hello web if the extensions are prepended.
We should prepend the extensions. Does merge prepend?

@edmorley
Copy link
Member

@piu130
Copy link
Contributor Author

piu130 commented Aug 31, 2018

Created a PR.

@edmorley edmorley added this to the v9 milestone Sep 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

2 participants