Fork me on GitHub
#cljsrn
<
2018-06-25
>
Joseph Hendrey07:06:20

Did you get anywhere with this? I noticed it today and discovered that metro/src/Server/index.js appends '.js' to everything in getOptionsFromUrl which seems to be where_ this is happening. I didn't spend enough time to work out why though.

carocad08:06:21

@jhendrey ah very interesting finding !! I have a theory of what is happening then. I think that the name of the file comes from the source maps that we are providing to the packager. Since those names contain the .js extension, the packager is most likely just taking that name and appending the second .js to it. I guess this is one of those “this only works with our worflow” kind of assumption in the packager. Similar to the sourcemaps themselves

carocad09:06:25

@jhendrey thanks to your wonderful insight I got it working now. It seems (at least on expo) that they change the extension of the file to flag different stages in the compilation. For example main.bundle and main.delta. This clashes with the sourcemaps since the filename already contains the extension. The fix is quite simple. Instead of always append js, append it only if the filename doesnt end with .js. I added some console.logs for before and after I did the patch.

carocad09:06:05

--------------------------------- BEFORE ------------------
10:59:02 [exp] Logs for your project will appear below. Press Ctrl+C to exit.
10:59:28 [exp] Launching Dev Tools...
10:59:33 [exp] _getOptionsFromUrl -> 
10:59:33 [exp] _pathname -> /main.delta
10:59:33 [exp] _entryFile -> main.js
10:59:35 [exp] Finished building JavaScript bundle in 2006ms.
10:59:37 [exp] You are now debugging remotely; check your browser console for your application logs.
10:59:42 [exp] _getOptionsFromUrl -> 
10:59:42 [exp] _pathname -> /main.bundle
10:59:42 [exp] _entryFile -> main.js
10:59:42 [exp] _getOptionsFromUrl -> 
10:59:42 [exp] _pathname -> /target/expo/reagent/impl/template.js
10:59:42 [exp] _entryFile -> target/expo/reagent/impl/template.js.js
10:59:42 [exp] NotFoundError: Cannot find entry file target/expo/reagent/impl/template.js.js in any of the roots: ["/Users/Camilo/Proyectos/hive"]
10:59:42 [exp]     at DependencyGraph.getAbsolutePath (/Users/Camilo/Proyectos/hive/node_modules/metro/src/node-haste/DependencyGraph.js:316:11)
10:59:42 [exp]     at /Users/Camilo/Proyectos/hive/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:280:416
10:59:42 [exp]     at Generator.next (<anonymous>)
10:59:42 [exp]     at step (/Users/Camilo/Proyectos/hive/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:11:445)
10:59:42 [exp]     at /Users/Camilo/Proyectos/hive/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:11:605
10:59:42 [exp]     at <anonymous>
10:59:42 [exp]     at process._tickCallback (internal/process/next_tick.js:188:7)

------------------------------------AFTER--------------------------------------
11:04:15 [exp] Logs for your project will appear below. Press Ctrl+C to exit.
11:04:20 [exp] _getOptionsFromUrl -> 
11:04:20 [exp] _pathname -> /main.delta
11:04:20 [exp] _entryFile -> main.js
11:04:21 [exp] Finished building JavaScript bundle in 898ms.
11:04:24 [exp] You are now debugging remotely; check your browser console for your application logs.
11:04:26 [exp] _getOptionsFromUrl -> 
11:04:26 [exp] _pathname -> /main.bundle
11:04:26 [exp] _entryFile -> main.js
11:04:26 [exp] _getOptionsFromUrl -> 
11:04:26 [exp] _pathname -> /target/expo/reagent/impl/template.js
11:04:26 [exp] _entryFile -> target/expo/reagent/impl/template.js
11:04:44 [exp] _getOptionsFromUrl -> 
11:04:44 [exp] _pathname -> /main.map
11:04:44 [exp] _entryFile -> main.js
11:04:44 [exp] Finished building JavaScript bundle in 687ms.
11:04:45 [exp] _getOptionsFromUrl -> 
11:04:45 [exp] _pathname -> /target/expo/env/expo/main.js.map
11:04:45 [exp] _entryFile -> target/expo/env/expo/main.js

carocad09:06:11

in case anybody is interested in the full description here is an open issue in our repo: https://github.com/hiposfer/hive/issues/105