forked from expo/expo
-
Notifications
You must be signed in to change notification settings - Fork 0
Local modules setup #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…extension module is present
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Setup for local modules, the most important changes are in:
Changes
packages/@expo/cli/src/start/server/metro/MetroBundlerDevServer.ts. Added and running startModuleGenerationAsync function (it's run on yarn start) in which we:metro.config.jsHere we make sure that import X from '**/file.nativeModule' resolve to the same relative path as from projectRoot but on the mirror ./expo/localModules directory, i.e. they now point to file.nativeModule.js which has requireNativeModule("file")tsconfig.jsonHere added proper include paths and root dirs:packages/@expo/metro-config/src/ExpoMetroConfig.ts. Here we addtsandswiftextensions so that the watcher can watch them.Thanks to them ts looks for types generated int ./expo/localModules
Expected behaviour
To see the changes cd to
apps/sandboxadd some .kt files for example 'test.kt', 'app/nested/test2.swift'. Now when you runyarn startyou should see a new directory .expo/localModules and you should see:after running the yarn start, when the watcher is active you can change these files and see the .expo/localModules directory update accordingly. For example:
adding
app/test3.ktshould create 2 new files.expo/localModules/app/test3.jsand.expo/localModules/app/test3.nativeModule.d.tsremoving 'app/nested/test2.swift' should result in removal of whole ./.expo/localModules/app/nested directory as it was the only file in there.
You can also try adding
test4.ktandtest4.swift, second add shouldn't add any new files as the test4.d.ts and test4.js files are the same (for now) for both kotlin and swift. Also if you remove one of them, the test4 files in ./expo/localModules should not be removed