I'd like to do the following and wondering if it's possible:
// create files
Foo.ios.js
Foo.android.js
Foo.web.js
import Foo from 'foo';
That might be more of a question for the React-Native folks since they're the ones that make the tools
The current packager code is here: https://github.com/facebook/react-native/tree/master/packager
You might be able to just add the change and submit a PR
Yeah, webpack should load *.web.js files by default. So if you're using that you build your web entry, it should work.
In order to make it also work with Typescript (*.web.tsand *.web.tsx) there 2 more actions required:
In web-pack configuration set following extensions:
extensions: ["", ".web.js", ".js", ".web.jsx", ".jsx", ".web.ts", ".ts", ".web.tsx", ".tsx"],
In tsconfig.json add following settings into the compilerOptions:
"baseUrl": ".",
"paths": {
"*": [
"*.web",
"*"
]
But this doesn't seem to work with server side code. Everything is taken to the default .js files. Any help ??
Most helpful comment
In order to make it also work with Typescript
(*.web.tsand*.web.tsx) there 2 more actions required:In web-pack configuration set following extensions:
extensions: ["", ".web.js", ".js", ".web.jsx", ".jsx", ".web.ts", ".ts", ".web.tsx", ".tsx"],In
tsconfig.jsonadd following settings into thecompilerOptions: