Uh oh!
There was an error while loading. Please reload this page.
feat: replace {{ packageName }} in deps' configuration - #871
Conversation
thymikee
left a comment
There was a problem hiding this comment.
Sounds good! Can we document it? :)
sjchmiela
commented
Nov 29, 2019
I should note this will unfortunately break |
Salakar
left a comment
There was a problem hiding this comment.
Can we not keep this backwards compatible for libraries such as CodePush that are using BuildConfig? I think we should if we can?
I'm not entirely sure why import ${packageName}.BuildConfig needs removing when you're adding it back via your module config?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
sjchmiela
commented
Nov 29, 2019
|
grabbou
commented
Jan 30, 2020
This is great - @sjchmiela - what is the status of it? Is this good to go? One of the previous comments mentions that this is potentially going to break CodePush. Was this already addressed? |
Libraries already expect to be able to use R and BuildConfig classes without having to worry about their packages. To match the expectations the script will replace un-fully-qualified references to fully-qualified.
sjchmiela
commented
Feb 3, 2020
No, it wasn't up until now! I have brought back support for eg. newCodePush(
getResources().getString(R.string.CodePushDeploymentKey),
getApplicationContext(),
BuildConfig.DEBUG
)by a middle step of replacing I have tested the change by manually copying the // 1newCodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG)
// 2newPackageR(), newRoyal(), Module.configure(other.package.BuildConfig)which printed // 1newCodePush(getResources().getString(com.test.sjchmiela.R.string.CodePushDeploymentKey), getApplicationContext(), com.test.sjchmiela.BuildConfig.DEBUG)
// 2newPackageR(), newRoyal(), Module.configure(other.package.BuildConfig)Let me know if this will be the proper way to go in your opinion. PS. I think the test failures weren't caused by this change. 🤔 |
Salakar
commented
Feb 3, 2020
Thanks for making this backwards compat @sjchmiela - LGTM |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
grabbou
left a comment
There was a problem hiding this comment.
Code-wise it all looks good - thank you! Just left a question to better understand it
grabbou
commented
Mar 19, 2020
The purpose of this PR was to enable a scenario where we don't import the There are scenarios where this would break the build. What this PR does is... rather than importing the As a result, when library author uses FQDN reference themselves, e.g. |
Summary:
Hard importing
${packageName}.Rand${packageName}.BuildConfighelps to install React Native modules which useRandBuildConfigwithout package prefix (eg.react-native-code-push, see #435 fixing #434.)BuildConfigimport has been introduced in #258, so right from the beginning (specific commit: 64f3f5a).This pull request:
{{ packageName }}inpackageImportPathandpackageInstancegeneratePackageListtask to libraries (imagine a project where its the submodule (:appdepends on ➡️:library) which depends on autolinked React Native modules)Test Plan:
I introduced these changes to my project, added to
react-native-maps'react-native.config.jsmodule.exports = { dependency: { platforms: { android: { sourceDir: './lib/android', + packageInstance: 'new MapsPackage({{ packageName }}.BuildConfig)',+ packageImportPath: 'import {{ packageName }}.R;\nimport com.maps;' }, }, }, };started the app, and
PackageList.javacontainedand