Skip to content
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

consider checking whether a babel ignore pattern is needed #3

Closed
carocad opened this issue Feb 26, 2019 · 4 comments
Closed

consider checking whether a babel ignore pattern is needed #3

carocad opened this issue Feb 26, 2019 · 4 comments

Comments

@carocad
Copy link

carocad commented Feb 26, 2019

currently your babel.config.js file only contains the preset for react native: https://github.com/thheller/reagent-expo/blob/master/babel.config.js#L4

In my app I had troubles on my CI pipeline because babel would to parse the main.js file generated by the cljs compiler for production. This would incur in build times of around 20 minutes; most of it just doing the packaging of js files. See this pr for "more info". After ignoring the compiled file my builds where significantly faster.

However, I think some people have had several issues with this approach because usually the output file is called index.js and (apparently) babel cannot differentiate the cljs compiled index.js file from any other module index.js file; it just compares the name and if they matched then the file is ignored.

I am not sure if this changed byt just wanted to mention it.

Hope it helps

@thheller
Copy link
Owner

thheller commented Feb 26, 2019

I did experiment with that. I however didn't seem to make much on an impact whether the files are filtered or not in release builds. Building the bundle takes about 30sec and the vast majority of time is spent converting things in node_modules.

I tried with babel.config.js

module.exports = function(api) {
  api.cache(true);
  return {
    presets: [],
    plugins: []
  };
};
[22:10:37] Unable to find an existing Expo CLI instance for this directory, starting a new one...
[22:10:40] Starting Metro Bundler on port 19001.
[22:10:42] Tunnel ready.
[22:10:42] Publishing to channel 'default'...
[22:10:44] Building iOS bundle
[22:11:12] Building Android bundle
Building JavaScript bundle [====================================================================================================] 100%
[22:11:12] Finished building JavaScript bundle in 26521ms.
[22:11:31] Analyzing assets
Building JavaScript bundle [====================================================================================================] 100%
[22:11:31] Finished building JavaScript bundle in 18220ms.
[22:11:31] Finished building JavaScript bundle in 873ms.
[22:11:32] Finished building JavaScript bundle in 826ms.
[22:11:32] Uploading assets
[22:11:33] No assets changed, skipped.
[22:11:33] Processing asset bundle patterns:
[22:11:33] - C:\Users\thheller\code\tmp\reagent-expo\**\*
[22:11:33] Uploading JavaScript bundles
[22:11:40] Published
[22:11:40] Your URL is

https://exp.host/@thheller/reagent-expo

Don't know how much this would change if there was more actual CLJS code.

This is using :advanced optimized code, not sure if that is used in other tools such as re-natal. :simple may take substantially longer to process.

@carocad
Copy link
Author

carocad commented Feb 27, 2019

NOTE: this is just a brain dump of my current understanding, please take it with a grain of salt as it might be wrong

AFAIK the presets are required for 3rd party components that are created with ES6 (react classes). Those ones need to be transpiled to work on older JavascriptCore engines.

I think Reagent doesnt use any magic for React components but creates them directly, which would explain why your build works even when you dont have any presets.

The other point that I think is relevant is that things like node.js "native" modules are replaced by the metro packager when building so that they actually use the mobile apis.

I think it would be interesting to see how does shadow-cljs work on a production app with non-trivial setup.

Hope it helps

@thheller
Copy link
Owner

thheller commented Feb 27, 2019

FWIW I took the hive project you linked above and compiled it using shadow-cljs and tried to publish it.

[12:28:42] Unable to find an existing Expo CLI instance for this directory, starting a new one...
...
[12:29:33] Building Android bundle
Building JavaScript bundle [====================================================================================================] 100%
[12:29:33] Finished building JavaScript bundle in 43672ms.
[12:30:08] Analyzing assets
Building JavaScript bundle [====================================================================================================] 100%
[12:30:08] Finished building JavaScript bundle in 35209ms.
[12:30:15] Finished building JavaScript bundle in 7107ms.
[12:30:21] (node:47160) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 change listeners added. Use emitter.setMaxListeners() to increase limit
[12:30:21] Finished building JavaScript bundle in 5862ms.
[12:30:21] Uploading assets
[12:30:22] No assets changed, skipped.
[12:30:22] Processing asset bundle patterns:
[12:30:22] - C:\Users\thheller\code\tmp\hive\expo\**\*
[12:30:22] Uploading JavaScript bundles
[12:30:32] Published
[12:30:32] Your URL is

https://exp.host/@thheller/HiveApp

The app doesn't actually run because I only created empty gtfs.json and config.json files I guess. It fails with some datascript error on startup.

Cannot store nil as a value at [:db/add 1 :session/uuid nil]

Deploy times seem fine though. Nothing excessive. This was with the default babel.config.js.

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"]
  };
};

Not sure what the app is actually supposed to do. Do you have some valid .json files for me? Maybe its not actually related to those, I'm not actually sure.

@carocad
Copy link
Author

carocad commented Feb 27, 2019

hey @thheller I will provide them to you later today.

But the bundling times look very good. I had built times of 20 minutes before so this is very good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants