Closed omatrot closed 6 years ago
Sorry that this isn't clear and for my long reply. This is because the build hasn't been configured to replace the nameof expressions. Are you using gulp or webpack or something else?
See the setup section on the readme. I'll update that to be at the top of the readme sometime in the future.
I would say that ReactXP is using webpack because I have a webpack.config.ts file.
Cool, I don't know enough about webpack, but I believe you should be able to follow the instructions at https://github.com/Kukks/ts-nameof-loader to use this with webpack.
It works !
To be more precise, for a ReactXP project (And probably a React one too), you have to install the loader as explained in the loader instructions and modify the webpack.config.ts
file as below:
Before
module: {
loaders: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
]
}
After
module: {
loaders: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader' and 'ts-nameof-loader'.
{ test: /\.tsx?$/, use: ["awesome-typescript-loader","ts-nameof-loader"] },
]
}
Sorry, this works only on ReactXP targeting web (using webpack). There is something to do for iOS and Android...
@dsherret It seems that we need a Babel plugin. Any help appreciated.
Ok I ended up using your custom setup and it works fine.
Following up on this... there is a new setup for webpack that allows you to easily inject this library as a custom transformer: https://github.com/dsherret/ts-nameof/blob/master/setup/webpack.md
Unfortunately this library doesn't work with babel. Read more here: https://github.com/dsherret/ts-nameof/issues/37#issuecomment-443548609
Interestingly, I was able to get things working via the ts-nameof-loader
, but not with the custom transformer. I may look into this more in the future, but for now I'll just use the loader.
I'm trying to use your utility in a ReactXP project. I've followed the instruction to reference the path. It compiles ok, but I have the following error at runtime on web:
On iPhone:
Android:
Any help appreciated.