Comments in the imported file via "require" should be removed.
Currently If you use "require" to import npm's lib (like in lib/ramda - $lib_ramda = require('ramda/src/index.js') as typeof import('ramda')) than comments will be not removed.
Example of generated web.js source
// ...
var $node = $node || {}
void function( module ) { var exports = module.exports = this; function require( id ) { return $node[ id.replace( /^.\// , "ramda/src/" ) ] };
;
/**
* A function that always returns `false`. Any passed in parameters are ignored.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Function
* @sig * -> Boolean
* @param {*}
* @return {Boolean}
* @see R.T
* @example
*
* R.F(); //=> false
*/
var F = function () {
return false;
};
module.exports = F;
;
$node[ "ramda/src/F" ] = $node[ "ramda/src/F.js" ] = module.exports }.call( {} , {} )
;
var $node = $node || {}
void function( module ) { var exports = module.exports = this; function require( id ) { return $node[ id.replace( /^.\// , "ramda/src/" ) ] };
;
/**
* A function that always returns `true`. Any passed in parameters are ignored.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Function
* @sig * -> Boolean
* @param {*}
* @return {Boolean}
* @see R.F
* @example
*
* R.T(); //=> true
*/
var T = function () {
return true;
};
module.exports = T;
;
$node[ "ramda/src/T" ] = $node[ "ramda/src/T.js" ] = module.exports }.call( {} , {} )
;
// ... and so on
You can require minified version: dist/ramda.min.js
You can require minified version:
dist/ramda.min.js
suddenly no! :) I don't know why, but ramda.min.js does not works, I tried to beatify ramda.min.js code and find reason, but failed. Error when I'm doing const {invertObj} = $lib_ramda:
Cannot destructure property 'invertObj' of '$.$lib_ramda' as it is undefined.
Similar problem might be actual for other modules used by "require"
Also another point why comments need to be removed, I can prepare some lib for myself with items that I will need:, e.g
export let $my_ramda = {
invertObj: require( 'ramda/src/invertObj.js' ) as typeof import( 'ramda' ).invertObj,
uniq: require( 'ramda/src/uniq.js' ) as typeof import( 'ramda' ).uniq,
concat: require( 'ramda/src/concat.js' ) as typeof import( 'ramda' ).concat,
mergeWith: require( 'ramda/src/mergeWith.js' ) as typeof import( 'ramda' ).mergeWith,
keys: require( 'ramda/src/keys.js' ) as typeof import( 'ramda' ).keys
}
and builder removes comments from mol's sources, but not from required files, there are no sense in vendor's lib's comments.
Comments from TS sources are removed by typescript. In the future we should use some bundler to import NPM modules. Current implementation is very limited.
agree, maybe no need to focus on it too much now. Yes, we can collect all import ... and require and bundle them separately with tree shaking, etc