![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
YA ComonJS to browser packer tool, well-suited for widgets by small overhead and big app by smart settings
YA ComonJS to browser packer tool, well-suited for tiny widgets by small overhead and big app by module replacement, node-environment emulations and multi-exports.
.js
- just put it to bundle as is.json
- wrap in module.exports
as node do it on require('file.json')
.coffee
- compile to JavaScript.eco
- precompile to JavaScript function.jade
- precompile it in client-mode wayThis possibility almost exists - clinch from 0.2.5 have API for third party processors, but template engine must support template-to-function precompilation.
More info and example - below at description of method registerProcessor()
For additional example - see using Handelbars - yap, now Hadlebars supported as add-on.
Compiled client-mode template may be used wia require()
. More information at './test', also examples was placed in wiki jade template engine. In browser should be pre-loaded Jade's runtime.js
.
npm install clinch
#!/usr/bin/env coffee
Clinch = require 'clinch'
packer = new Clinch runtime : on
pack_config =
package_name : 'my_package'
bundle :
main : "#{__dirname}/hello_world"
packer.buildPackage pack_config, (err, data) ->
if err
console.log 'Builder, err: ', err
else
console.log 'Builder, data: \n', data
Content of ./hellow_world
###
This is 'Hello World!' example
###
module.exports =
hello_world : -> 'Hello World!'
Now data
contain something like this
(function() {
'use strict';
var dependencies, sources, require, modules_cache = {};
dependencies = {};
sources = {
"JPGt0": function(exports, module, require) {
// /Users/meettya/github/clinch/example/hello_world/hello_world.coffee
/*
This is 'Hello World!' example
*/
module.exports = {
hello_world: function() {
return 'Hello World!';
}
};
}};
if(this.clinch_runtime_v2 == null) {
throw Error("Resolve clinch runtime library version |2| first!");
}
require = this.clinch_runtime_v2.require_builder.call(this, dependencies, sources, modules_cache);
/* bundle export */
this.my_package = {
main : require("JPGt0")
};
}).call(this);
And in browser function may be accessed in this way
hello_world = my_package.main.hello_world
clinch have minimalistic API
packer = new Clinch clinch_options
clinch_options
- Clinch settings
packer.buildPackage package_config, cb
# or old form, will be deprecated in new version
packer.buildPackage package_name, package_config, cb
package_name
- root bundle package name (like $
for jQuery), remember about name collisions, may be omitted. Will be deprecated in new versions, use package_config.package_name
package_config
- package settings
cb
- standard callback, all in clinch are async
packer.registerProcessor file_extention, fn
This method allow to register any file content processor, which will be used to process files with file_extention
.
file_extention
- file extension to proceed
fn
- processor function
Example:
# add .econ processor
packer.registerProcessor '.econ', (file_content, filename, cb) ->
content = Eco.precompile file_content
cb null, "module.exports = #{content}"
At now clinch will be compile all required .econ
files with this function.
And in module code:
template = require './template' # ./template.econ, extension may be omitted
res = template data # res now is some html-contented string
packer.flushCache()
This method will force flush packer cache. As usually clinch flush cache if files changed, but for some rare cases its available to force it.
packer.getPackageFilesList package_config, cb
This method will return an Array of all files, used in package building process.
May be used for custom watch
implementation or in other cases
log : off # will add verbose output, but now not realized yet
strict : on # knob for 'use strict;' in bundle header
inject : on # if changed to 'off' - bundle will not to inject 'package_name' to global
runtime : off # use internal boilerplate code, or as external file
cache_modules : on # by default all resolved by 'require' file will be cached, if you have some problem - turn cache off and notice me
###
this settings will be applied to jade.compile() function
###
jade :
pretty : on
self : on
compileDebug : off
###
May be omitted. If omitted - inject all bundle members to global OR, if `inject : off` in package settings - make all bundle members local for bundle (it may be usefully in case of widgets with self-detection)
###
package_name : 'bundle_pack_name'
# bundle settings
strict : on # bundle knob for 'use strict;' in bundle header
inject : on # if changed to 'off' - bundle will not to inject 'package_name' to global
runtime : off # use internal boilerplate code, or as external file
cache_modules : on # by default all resolved by 'require' file will be cached, if you have some problem - turn cache off and notice me
###
At least one key must be exists
name -> code place
this keys was be exported when script loaded
bundle =
main : function(){...}
helper : function(){...}
later in code
main = bundle.main
###
bundle :
main : './src'
helper : './src/lib/helper'
###
This is local for code variables, to imitate node.js environment,
or replace somthing
Important - keys will be used as variable name, so any strange things may happened
if it not old plain string, remember it!!!
###
environment :
process : './node/js-process'
console : './node_modules/console-shim'
###
This part replace modules with browser-spec one
###
replacement :
util : './node_modules/js-util'
lodash : -> @_ # yes, its allowed to use function instead of file (`this` will be pointed to global scoop)
###
this is list of modules, which is not be placed in bungle
###
exclude : [
'underscore'
]
###
This is list of modules, which we are not check for require in it
save time with huge pre-bulded libraries, like `lodash` or `jquery`
if we are decide to place it in bundle
###
requireless : [
'lodash'
]
See example
or test
dirs.
Also some examples will be available online at clinch_demo.
Also clinch will be used to browser-pack TinyData, see sources and packed lib
Its exists README_ru version of documentation, with more information.
0.5.3 / 2014-04-01 12:00 AM
FAQs
YA ComonJS to browser packer tool, well-suited for widgets by small overhead and big app by smart settings
The npm package clinch receives a total of 20 weekly downloads. As such, clinch popularity was classified as not popular.
We found that clinch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.