Fork me on GitHub
#cljsrn
<
2016-07-25
>
pesterhazy19:07:38

@boorad: are you still looking into BRN? Made some progress on that front

boorad19:07:19

I am… I commented on #49

boorad19:07:29

and did more research today

boorad19:07:42

but have to run now… bbl

boorad19:07:13

I’m looking at why the response or result in node-haste comes back with dependencies: [] instead of dependencies: undefined

boorad19:07:32

and trying to trigger the extractor fun

pesterhazy19:07:59

@boorad: I replied to #49

pesterhazy19:07:20

let's chat about it when you have time

boorad20:07:41

@pesterhazy: I’m here again, for a bit. Do we need to make our own channel, #boot-react-native?

pesterhazy20:07:00

hehe, I think this is find as a place to discuss this

boorad20:07:28

ok, so I haven’t looked at your develop branch - what did you do?

pesterhazy20:07:30

did you see my minimal example?

pesterhazy20:07:31

I this demonstrates what doesn't work: node-haste finds "aurevoir.js" as a dep, but not "goodbye.js"

boorad20:07:53

ah, goog.base gets the full app name

boorad20:07:43

right, so you do the s/goog.require/require/g thing

pesterhazy20:07:17

also if I add a console.log to extractRequires.js, it never prints

pesterhazy20:07:17

so the regex is not actually used; instead the packager uses some other way to discover "require"s -- but which?

boorad20:07:22

that’s where my tracing led me.

boorad20:07:34

I got the code to go through extractRequires

pesterhazy20:07:34

it's a mystery 🙂

pesterhazy20:07:11

I really wonder how it can extract it (if you search for "require", there's not other match inside node-haste)

pesterhazy20:07:27

how did you re-route the code?

boorad20:07:27

it wasn’t going to extractor function because in node-haste Module/index.js it checks for dependencies === undefined, but always returns []

boorad20:07:02

I also redid the convoluted inline conditionals to more overt if else stmts, so I could control it

boorad20:07:34

once in extractRequires, you and Matt are correct. There’s no difference between goog.require and require. It gets them all.

pesterhazy20:07:31

the question is, how does it usually do the extraction, if not through the regex?

boorad20:07:04

I’m not sure.

boorad20:07:49

I may have come across another extractor… hold on

pesterhazy20:07:20

the code is crazy hard to read (ES6 is not necessarily an improvement, apparently)

boorad20:07:47

yeah, noticed that myself

boorad20:07:55

JSTransform/worker/inline.js

boorad20:07:53

maybe Resolver/polyfills/require.js

boorad20:07:59

I’ve done the export DEBUG=React… thing, didn’t help too much

boorad20:07:12

btw, I have a master branch with a couple of changes myself...

boorad20:07:18

different direction from your develop branch

pesterhazy20:07:36

cool, where are you heading?

boorad20:07:51

getting react-native and node-haste to talk correctly

boorad20:07:07

not your regex replace thing

boorad20:07:24

getting extractRequires called

boorad20:07:52

your question is correct, how does rn work right now, without our transformer?

boorad20:07:08

what does your little example do with the out-of-the-box transformer in use?

boorad20:07:18

not cljs-rn-transformer.js?

pesterhazy20:07:21

it's the same thing

pesterhazy20:07:30

require gets picked up, goog.require doesn't

pesterhazy20:07:42

so it has nothing to do with the cljs-rn-transformer.js

boorad20:07:07

yeah, cuz our transformer uses the default one, unless it says “Generated by ClojureScript” or something like that

pesterhazy20:07:37

and even then I think it only touches the source map (but I'm not sure)

boorad20:07:05

getResolvedDependencyPairs ?

boorad20:07:06

so they take their extractor out and put it into a separate lib (node-haste) and then bypass it? WTF?

boorad20:07:43

wonder what calls wrapModule...

pesterhazy20:07:09

yeah but looking at the packager code, I can't make head or tails of it

boorad20:07:03

that calls wrapModule that goes ahead and does that non-haste requires code

boorad20:07:45

what a shit-show

pesterhazy20:07:07

so the actual code for extracting requires isn't actually in node-haste 🙂

pesterhazy20:07:29

>>> * Extracts dependencies (module IDs imported with the require function) from * a string containing code. * The function is regular expression based for speed reasons.

pesterhazy20:07:54

^^ I think this is not true.. it actually uses babel to parse the js, not regex 🙂

boorad20:07:56

wait… the extract-dependencies.js is the one that I had seen earlier

boorad20:07:55

so that one is where Bundler/Resolver might be calling to haste

boorad20:07:36

constructor of that one sets dependencies to [], which I’ve seen in my tracing

boorad20:07:49

which path does it take? There are plenty of requires parsers in these code bases

pesterhazy20:07:08

and it gets called at the right time, so that must be the place

boorad20:07:28

what’s path?

boorad20:07:51

maybe that’s on non-cljs-generated sources?

pesterhazy20:07:33

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' }

pesterhazy20:07:54

that's the output of adding

console.log("xxxxbabel", callee.type, callee.name, arg);

pesterhazy20:07:45

"MemberExpression" because it's a .member -- makes sense

boorad20:07:55

so that’s the transform step, using their default transformer

pesterhazy20:07:28

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 }

pesterhazy20:07:35

basically, goog.require

pesterhazy20:07:54

so we can patch the packager to discover goog.require too

pesterhazy20:07:57

would that help?

boorad20:07:09

I think so

boorad20:07:19

can we do it in .babelrc in any way?

pesterhazy20:07:29

I know nothing whatsoever about babel 😞

pesterhazy20:07:58

we'd need to carry a patch to react-native (unless they merge our patch, which seems unlikely)

boorad21:07:35

I came across a patch that allowed more config in .babelrc, and another one to do transforms first for various reasons

boorad21:07:48

I don’t know anything about babel either

boorad21:07:55

gotta run, back online later tonight

pesterhazy21:07:33

I'm on European time, so will be back online tomorrow

pesterhazy21:07:44

we made some progress I think 🙂