Feature/replace build system #131
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Pull request for cloudinary/frontend-frameworks
For which package is this PR?
React
What does this PR solve?
This PR solves the incorrect
mainproperties (closes #101, #128, replaces #129)Root cause:
The root cause of this issue is the microbundle library which makes heavy assumptions on how the package will look like.
Microbundle connects two different properties into a single use case, the output folder.
Microbundle will decide the output folder based on the
mainproperty, in our case this is problematic since on build, we want the output to be./dist/index.jsyet we want the actual value of main in package.json to be./index.jsThis contradiction, which cannot seem to be resolved by configuration, makes the library irrelevant for our use case.
Initial fix:
My initial fix was to replace microbundle with rollup, this surfaced a new problem - type declarations were being generated under
./dist/srcinstead of./dist.after some investigation, I reached this link which describes how an import from outside
srcwill cause output directory to contain thesrcdirectory.I then realized we're importing the
package.jsonfile to resolve the version of the package for the SDK analytics.I replaced the package.json import with a string-replace solution.
I finished up by adding tests that ensure the build generates the desired output.
Testing:
Aside from the jest test that was added, I manually verified the package can be installed and types are accurately displayed by the IDE.
Final checklist