forked from dmotz/natal
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Feature/v57 #192
Merged
Merged
Feature/v57 #192
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
{ | ||
"name": "re-natal", | ||
"version": "0.9.0", | ||
"description": "Bootstrap ClojureScript React Native apps with reagent and re-frame for iOS and Android", | ||
"description": "Bootstrap ClojureScript React Native apps with reagent, re-frame and om next for iOS and Android", | ||
"main": "index.js", | ||
"author": "Artur Girenko <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"chalk": "^1.1.1", | ||
"chalk": "^2.4.1", | ||
"check-dependencies": "^1.0.1", | ||
"coffeescript": "^1.9.3", | ||
"coffeescript": "^2.3.2", | ||
"commander": "^2.8.1", | ||
"deepmerge": "^1.5.2", | ||
"fs-extra": "^0.26.5", | ||
"deepmerge": "^2.1.1", | ||
"fs-extra": "^7.0.0", | ||
"handlebars": "^4.0.10", | ||
"klaw-sync": "^2.1.0", | ||
"klaw-sync": "^5.0.0", | ||
"semver": "^5.0.1" | ||
}, | ||
"engines": { | ||
|
@@ -37,7 +37,8 @@ | |
"ios", | ||
"android", | ||
"reagent", | ||
"re-frame" | ||
"re-frame", | ||
"om next" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/drapanjanas/re-natal/issues" | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
This is a custom React Native/Metro Transformer to fix issues | ||
with bundling a large single JS file. It works with RNv0.57. | ||
|
||
Add the command below to package.json or project.clj. | ||
node --expose-gc --max_old_space_size=8192 \ | ||
'./node_modules/react-native/local-cli/cli.js' bundle \ | ||
--sourcemap-output main.jsbundle.map \ | ||
--bundle-output ios/main.jsbundle \ | ||
--entry-file release.ios.js \ | ||
--platform ios \ | ||
--dev true \ | ||
--assets-dest ios \ | ||
--config=./rn-cli.config.js", | ||
*/ | ||
|
||
var DEBUG = true; | ||
var debug = DEBUG ? | ||
function(){ console.log.call(this, [].slice.call(arguments)); } : | ||
function(){}; | ||
|
||
// Big files can slow down Metro, so we'll dump GC every 30 seconds to be safe. | ||
(function scheduleGc() { | ||
if (!global.gc) { | ||
console.log("Garbage collection is not exposed"); | ||
return; | ||
} | ||
|
||
var timeoutId = setTimeout(function() { | ||
global.gc(); | ||
console.log("Manual gc", process.memoryUsage()); | ||
scheduleGc(); | ||
}, 30 * 1000); | ||
timeoutId.unref(); | ||
})(); | ||
|
||
// Custom Metro Transform (validated with React Native v0.57) | ||
var path = require("path"); | ||
var fs = require("fs"); | ||
var defaultTransformer = require("./node_modules/metro/src/reactNativeTransformer"); | ||
|
||
function clojurescriptTransformer(code, filename) { | ||
console.log("Generating sourcemap for " + filename); | ||
var map = fs.readFileSync(filename + ".map", { encoding: "utf8" }); | ||
var sourceMap = JSON.parse(map); | ||
|
||
var sourcesContent = []; | ||
sourceMap.sources.forEach(function(path) { | ||
var sourcePath = __dirname + "/" + path; | ||
var isDirectory = path.indexOf(".") === -1; | ||
if (isDirectory) { | ||
debug("ignore"); | ||
return; | ||
} | ||
|
||
try { | ||
// try and find the corresponding `.cljs` file first | ||
var file = sourcePath.replace(".js", ".cljs"); | ||
debug(file); | ||
sourcesContent.push(fs.readFileSync(file, "utf8")); | ||
} catch (e) { | ||
// otherwise fallback to whatever is listed as the source | ||
debug("sourcePath", path); | ||
try { | ||
sourcesContent.push(fs.readFileSync(sourcePath, "utf8")); | ||
} catch (e) { | ||
if (sourcePath.match(/\.js$/) !== null) { | ||
console.warn("clojurescript transformer error with file ", sourcePath); | ||
} | ||
} | ||
} | ||
}); | ||
sourceMap.sourcesContent = sourcesContent; | ||
|
||
return { | ||
filename: filename, | ||
code: code.replace("# sourceMappingURL=", ""), | ||
map: sourceMap | ||
}; | ||
} | ||
|
||
|
||
var customClojurescriptTransformer = function(data){ | ||
var isCljsEntryFile = data.filename.match(/index\.*\.js/) !== null; | ||
console.log('d', data.filename); | ||
if (isCljsEntryFile) { | ||
debug("using custom clojurescript transformer"); | ||
return clojurescriptTransformer(data.src, data.filename); | ||
} else { | ||
return defaultTransformer.transform(data); | ||
} | ||
} | ||
|
||
// @see https://facebook.github.io/metro/docs/en/configuration | ||
var rnCliConfig = { | ||
projectRoot: path.resolve(__dirname), | ||
getTransformModulePath: () => require.resolve("./rn-cli.config") | ||
} | ||
|
||
module.exports = { | ||
transform: customClojurescriptTransformer, | ||
projectRoot: projectRoot, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get an error here This line should probably be |
||
getTransformModulePath: rnCliConfig.getTransformModulePath | ||
}; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails if there is no yarn:
Leave it as false for now?