This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-25
Channels
- # admin-announcements (2)
- # beginners (36)
- # boot (37)
- # cider (65)
- # cljsrn (92)
- # clojars (3)
- # clojure (225)
- # clojure-austin (5)
- # clojure-belgium (2)
- # clojure-brasil (3)
- # clojure-china (1)
- # clojure-greece (2)
- # clojure-mexico (3)
- # clojure-news (2)
- # clojure-quebec (1)
- # clojure-russia (14)
- # clojure-spec (24)
- # clojure-uk (53)
- # clojurescript (34)
- # cursive (14)
- # datascript (9)
- # datomic (4)
- # defnpodcast (8)
- # devcards (30)
- # dirac (7)
- # editors (7)
- # emacs (1)
- # figwheel (1)
- # hoplon (85)
- # immutant (2)
- # incanter (1)
- # luminus (5)
- # off-topic (41)
- # om (18)
- # onyx (11)
- # perun (2)
- # re-frame (11)
- # reagent (9)
- # ring (3)
- # spacemacs (2)
- # spirituality-ethics (1)
- # test-check (19)
- # testing (12)
- # untangled (14)
- # yada (9)
@boorad: are you still looking into BRN? Made some progress on that front
I’m looking at why the response or result in node-haste comes back with dependencies: [] instead of dependencies: undefined
@boorad: I replied to #49
let's chat about it when you have time
@pesterhazy: I’m here again, for a bit. Do we need to make our own channel, #boot-react-native?
hehe, I think this is find as a place to discuss this
did you see my minimal example?
I this demonstrates what doesn't work: node-haste finds "aurevoir.js" as a dep, but not "goodbye.js"
right
also if I add a console.log to extractRequires.js, it never prints
so the regex is not actually used; instead the packager uses some other way to discover "require"s -- but which?
it's a mystery 🙂
I really wonder how it can extract it (if you search for "require", there's not other match inside node-haste)
how did you re-route the code?
it wasn’t going to extractor function because in node-haste Module/index.js it checks for dependencies === undefined, but always returns []
I also redid the convoluted inline conditionals to more overt if else stmts, so I could control it
once in extractRequires, you and Matt are correct. There’s no difference between goog.require and require. It gets them all.
the question is, how does it usually do the extraction, if not through the regex?
the code is crazy hard to read (ES6 is not necessarily an improvement, apparently)
cool, where are you heading?
it's the same thing
require gets picked up, goog.require doesn't
so it has nothing to do with the cljs-rn-transformer.js
maybe it actually finds it here? https://github.com/facebook/react-native/blob/bd60d828c5fc9cb066e5f647c87ecd6f70cb63a5/packager/react-packager/src/Resolver/index.js#L194
yeah, cuz our transformer uses the default one, unless it says “Generated by ClojureScript” or something like that
exactly
and even then I think it only touches the source map (but I'm not sure)
so they take their extractor out and put it into a separate lib (node-haste) and then bypass it? WTF?
yeah but looking at the packager code, I can't make head or tails of it
so the actual code for extracting requires isn't actually in node-haste 🙂
>>> * Extracts dependencies (module IDs imported with the require
function) from
* a string containing code.
* The function is regular expression based for speed reasons.
^^ I think this is not true.. it actually uses babel to parse the js, not regex 🙂
https://github.com/boorad/node-haste/blob/master/src/DependencyGraph/ResolutionResponse.js#L91
so I added console.log here: https://github.com/facebook/react-native/blob/master/packager/react-packager/src/JSTransformer/worker/extract-dependencies.js#L35
and it gets called at the right time, so that must be the place
xxxxbabel MemberExpression undefined Node {
type: 'StringLiteral',
start: 13,
end: 27,
loc:
SourceLocation {
start: Position { line: 1, column: 13 },
end: Position { line: 1, column: 27 } },
extra: { rawValue: './goodbye.js', raw: '\'./goodbye.js\'' },
value: './goodbye.js' }
xxxxbabel Identifier require Node {
type: 'StringLiteral',
start: 38,
end: 53,
loc:
SourceLocation {
start: Position { line: 2, column: 8 },
end: Position { line: 2, column: 23 } },
extra: { rawValue: './aurevoir.js', raw: '\'./aurevoir.js\'' },
value: './aurevoir.js' }
that's the output of adding
console.log("xxxxbabel", callee.type, callee.name, arg);
"MemberExpression" because it's a .member
-- makes sense
that's callee:
xxxxcallee Node {
type: 'MemberExpression',
start: 0,
end: 12,
loc:
SourceLocation {
start: Position { line: 1, column: 0 },
end: Position { line: 1, column: 12 } },
object:
Node {
type: 'Identifier',
start: 0,
end: 4,
loc: SourceLocation { start: [Object], end: [Object] },
name: 'goog' },
property:
Node {
type: 'Identifier',
start: 5,
end: 12,
loc: SourceLocation { start: [Object], end: [Object] },
name: 'require' },
computed: false }
basically, goog.require
so we can patch the packager to discover goog.require
too
would that help?
I know nothing whatsoever about babel 😞
we'd need to carry a patch to react-native (unless they merge our patch, which seems unlikely)
I came across a patch that allowed more config in .babelrc, and another one to do transforms first for various reasons
I'm on European time, so will be back online tomorrow
we made some progress I think 🙂