I've found at least two ways to import functions in from a module like Ramda for example. There are probably a few more ways to do something very similar like const R = require('ramda');
Option 1 is to import certain functions:
import { cond, T, always, curry, compose } from 'ramda';
Option 2 is to import the whole module like:
import * as R from "ramda";
I would prefer to reference the module from which the function is being called like so:
R.T();
But if the 2nd option is used, does it bring in every Ramda function not just the ones used in a module I'm working in? Are there any impacts on actual memory use, or bandwidth use as far as what gets sent to the browser if option 2 is used? Is it possible to somehow do this:
// invalid syntax below:
import R { cond, T, always, curry, compose } from 'ramda';
R.T();
My question is kinda related to this one, but it's a bit different import R (ramda) into typescript .ts file
import … from 'ramda'
does by default always bring in the whole Ramda module, regardless whether you use named or namespaced imports. If there is any size optimisation (with guessing what parts of the module need to be evaluated and which not), then that happens in your module bundler (like Rollup). Contact its documentation. Usually it should be able to detect which imports you are using regardless of the import style, unless you are doing unusual things with the namespace object (like looping it or using dynamic property access). – Schizophreniaeval(fs.readFile(…))
(more or less) :-) I was talking about the declarative ES6 module syntax only. – Schizophrenia