Hi guys,
I'm currently working on a React Native library (@nartc/react-native-barcode-mask) and tsdx has been working great for me. However, I found it pretty frustrated to test out new features/bug fixes without an example application.
I've been trying to setup an example application that lives outside of the src directory of the lib and trying to link the library source (or dist) to use as a local dependency inside of the example application, but it hasn't been good. I've tried:
yarn link@nartc/react-native-barcode-mask: "file:./../" or "link:./../" inside example/package.jsonmodule-resolver to resolve the module with the path to ../dist A clear guide/documentations on how to setup an example application (with live reload if possible) for React Native library.
Again, here's the repo of the library: @nartc/react-native-barcode-mask
Any help, at all, is much appreciated. TIA!
PS: Great work on tsdx.
@nartc you can setup babel-plugin-module-resolver manually
https://github.com/jaredpalmer/tsdx/pull/374#issuecomment-567687288
meanwile https://github.com/jaredpalmer/tsdx/pull/374 in progress
BTW example from current template react-storybook also do not work
@ambroseus Thanks. I've tried setting up module-resolver and probably didn't know what I was doing so it didn't work. There's one weird problem was:
example/babel.config.js. Then the Metro Bundler would load 100% of the bundle, but as soon as the app's about to start, I got: Module AppRegistry is not a registered callback... error.After spending hours to get this setup properly without success, I've currently settled with a hack. Override tsdx with tsdx.config.js to have the build output directly to example/{package_name} which results in the output of the library is just like another module in the example application.
Pros: Setup is easy. Setup a script dev: tsdx watch --localDev. localDev will be available as options.localDev in tsdx.config.js. Use this flag to override config.output.file
Cons: Without further config needed, this hack requires the example app to be in JavaScript instead of TypeScript.
@nartc cool)) can you please add your solution to https://github.com/jaredpalmer/tsdx/issues/379
@ambroseus Done
Closed as the "hack-around" is sufficient for my use-case enough.
Most helpful comment
After spending hours to get this setup properly without success, I've currently settled with a hack. Override
tsdxwithtsdx.config.jsto have the build output directly toexample/{package_name}which results in the output of the library is just like another module in theexampleapplication.Pros: Setup is easy. Setup a script
dev: tsdx watch --localDev.localDevwill be available asoptions.localDevintsdx.config.js. Use this flag to overrideconfig.output.fileCons: Without further config needed, this hack requires the
exampleapp to be in JavaScript instead of TypeScript.