Détail du package

urequire

anodynos3.1kMIT0.7.0-beta.33

Convert AMD & commonjs modules to UMD, AMD, commonjs or combined.js (rjs & almond) & run/test on nodejs, Web/AMD or Web/Script. Manipulate & inject module code & dependencies while building & more

javascript, convert, commonjs, AMD

readme

uRequire v0.7.0-beta.33

Beta release note

Docs / wiki / http://uRequire.org mainly are Work In Progress (in transition from v0.6.x) - but everything should work except you'll need npm install urequire-cli -g & npm install urequire locally (if you are using the CLI urequire instead of the the recommended grunt-urequire). Check uRequire's master config / docs for up to date usage.

Build Status Up to date Status

The JavaScript Universal Module & Resource Converter (and automagical builder, test runner and more)...

All documentation is moved to the wiki and http://urequire.org

What's uRequire ?

For a quick taste of how much uRequire rocks, with minimal grunting or gulping, check urequire-example-helloworld. With just ~30 lines of DRY & declarative uRequire config, this example shows off the automagical :

  • transparent compilation from coffee-script, coco, LiveScript etc to javascript. They are all javascript, right ?

  • conversion from AMD or CommonJs (or a combination of both) to UMD or combined (<script>, AMD & nodejs compatible) javascript.

  • importing of dependencies (i.e dependencies: imports: lodash: ['_']) and keys out of them (resources: ['import-keys', {'chai': 'expect'} ] ]) to all modules in the bundle (held by some variable name). The latter uses the urequire-rc-import-keys ResourceConverter plugin.

  • injection of a var VERSION = 'x.x.x'; in main module's body, where 'x.x.x' comes from package.json (using the urequire-rc-inject-version ResourceConverter plugin).

  • gereration of a standard banner, with info from package.json.

  • declarative exporting of main module on window.myModule (with noConflict() baked in).

  • minification with uglify2's passing some rudimentary options.

  • discovery of dependencies's paths using the info already in bower or nodejs's npm.

  • generated tests that run on nodejs & phantomjs (browser) via mocha (& chai), both as Web/AMD & Web/Script. It even generates the required HTML, with all module's paths, requirejs's configs & shims or <script ...> tags etc.

  • watch facility with rapid rebuilds, since it compiles only files that have really changed and also runs the tests only if a) there were changes and b) with no compilation errors.

  • clean of destination files / folders before each build.

  • deriving (i.e like inheritance in OO) of configs.

  • passing r.js options

  • a cross module systems development, cross runtimes deployment & automagical continuous testing.

  • and last but not least: The elimination of (the need for) grunt plugins. There's isnt any hint of grunt-xxx for watch, coffee-script, browserify, uglify, mocha, concat, phantomjs, banner, clean etc). This is great news cause cause grunt plugins have many disadvantages :

    • repeating the same source & dest paths & files all over again (when you should keep it DRY)

    • you have to learn the intricacies & syntax of each plugin

    • making sure they run in the right order & hope they produce the right result

    • producing many intermediate temp files

    • building everything with each change etc

    • writing stuff for things that should be automagical ;-)

Who's gulping ?

Support uRequire

  • @goto('http://github.com/anodynos/urequire').then -> @star() with your love :-)

  • Flattr donate button PayPayl donate button

  • Get me hired me in a cool nodejs-loving team in London, UK (as of March 2015 ;-)

License

The MIT License

Copyright (c) 2013-2015 Agelos Pikoulas (agelos.pikoulas@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

changelog

v0.6.19 (2014-08-04) - Latest release

  • require('./some/dirName') is converted to require('./some/dirName/index') so it works on AMD / UMD

v0.6.18 (2014-06-02)

  • updating outdated deps (except gaze@v0.5.x)

  • travis tests only for node@v0.10

  • ignoring "raw" in esprima.parse / AST v1.x

v0.6.16 & v0.6.17

  • Discarded / unreleased

v0.6.15 (2014-04-29)

  • FIXED: AMD params with no/empty deps array was missintepreted fix #56

  • FIXED: AMD deps with no params not loading on nodejs template (module.nodeDeps was lacking + template ommited)

v0.6.14 (2014-04-24)

v0.6.13 (2014-02-27)

  • build.noLoaderUMD & build.warnNoLoaderUMD: fixes #53

  • fixed: 1st AMD dep would be included even if no params where present

0.6.12 (2013-02-20)

  • fixed: #50 nodejs template missing 'var' in deps

0.6.11 (2013-02-05)

  • Mainly internals / configs fixes

  • _.flatten configs on new BunlderBuilder

  • resources: resources: '|': 'arrayizeConcat' (properly)

  • blendConfigs: withMaster

  • lazily export urequire (fixes circular deps)

  • exportsRoot variables can be non-var symbols (_.underscored)

v0.6.10 (2013-12-20)

  • IMPROVED: Module::replaceDep works with partial/translation, minimatch, regexp, callback fix #41

  • NEW: build.clean works for all templates fix #44

  • NEW: build.dummyParams option

  • IMPROVED: less verbose errors/debug messages

  • IMPROVED: banner on combined works always (independently of requirejs.optimize)

  • IMPROVED: adding function callback for derivation (arrayConcat etc) & always pssing a _.clone parent

v0.6.9 (2013-12-07)

ResourceConverters:

  • ResourceConverters.filez default = /./
  • enabled, default true
  • added wrapCoffeeDefineCommonJS RC, enabled: false

CHANGE: bundle.dependencies: node

  • module / Dependency with isNode problem
  • @type 'arrayizeConcat'

NEW: bundle.dependencies.locals as depsVars type

NEW: build.isInjectExportsModule: true

  • 'solves' circular dependencies on AMD
  • useStrict works properly per module or per template / booleanOrFilespecs

Refactoring / bug fixing

  • Dependencies type & isXXX
  • templates:
    • rootExportsNoConflict returnModule param
    • removed ';' from end, templated-module might be reused
  • FIXED: useStrict undefined semantics on rjs
  • FIXED: better error / stack handling
  • FIXED: depsReporter _.pad
  • FIXED: nodeOnlyDep -> _.slugify excludedDep

v0.6.8 - (2013-12-02)

This release has many improvements, despite the 0.0.1 increase :-) Not touching 0.7 issues yet, but workings are important towards 0.7 & 1.0 :-)

  • New: Merging of code sections of injected code in modules & bundles

  • New: ['useStrict', 'bare', 'globalWindow', 'runtimeInfo', 'allNodeRequires', 'noRootExports', 'scanAllow']

    • @derive = 'arrayPushOrOverwrite'

    • @type = 'booleanOrFilespecs'

  • New: template.banner working for normal & combined template

  • Fixed: combined template was confusing local dependencies's varNames, in some rare cases

  • Improved/shorter reporting

  • Documentation is lighter & more generic

    • splitting [tags-Legend] & [types-and-derive]

    • adding more subtle types

    • adding linkage

    • Ovehaul of urequire.org splash page

  • Internal / Refactorings

    • Makeover of ModuleTemplate/AlmondTemplate with @sp & merging of sections

    • Generic code-manipulation related code, moved to /codeUtils (mainly from Module)

    • Dependency.type 'global' now called 'local'

    • More specs for isFileInSpecs

    • Dependency.type 'node' & isNode

    • RCs: throw when non-module has module flags + specs

    • Bundle: glob filters files only with */

    • Removed lodash dependency, used from B.

v0.6.7 - (2013-11-17)

  • build: useStrict, bare, globalWindow, runtimeInfo can be truthy or filez spec.

  • template: {combinedFile:'xxx'} works independently of dstPath, but each acts as default to the other if missing

  • optimize works for all templates, not only 'combined' ('uglify2' only).

0.6.6 - (2013-11-08)

  • Fixed build.globalWindow is now using the enclosing IFI function to pass window or global, works well with "use strict" (but not with build.bare).

  • Change: nodejs template is bare:false by default.

0.6.5 - (2013-10-29)

0.6.4 - (2013-10-20)

  • Added 'UMDplain' template

  • revised root exports in UMD/AMD/nodejs templates

0.6.3 - (2013-10-19)

0.6.2 - (2013-10-01)

  • Added preliminary support for srcMain on RCs/FileResources.

  • Added working RC examples for srcMain - execSync (sync external processes) & lessc (LESS-to-css) - see External-Processes.

  • Fixed bugs in RC.registry & cloning.

0.6.1 - (2013-09-26)

  • formally enabling & documenting build.out, as alternative to default resource.save()

0.6.0 - (2013-09-24)

  • Module dependencies / factory extraction :

    • new: esprima / Mozilla Parser AST is used for module information extraction. All functionality of ModuleManipulator/seekr is moved to Module, which is hugely refactored and improved.

    • new: Module has replaceCode, beforeBody, afterBody, injectDeps, replaceDep etc that alter the AST / dependencies (used in isBeforeTemplate ResourceConverters).

  • ResourceConverters (bundle.resources):

    • Breaking from 0.4/0.5 The value of this in convert() is the RC instance, not the Resource/Module instance (which is passed as the 1st -and only- argument).

    • new: isBeforeTemplate '+' flag, passing a Module with extracted dependencies information and AST manipulation facilities, just BEFORE the template rendering.

    • new: search function can accept an Array or Function spec, returning a materialized and registered RC.

    • fixed: watching bug in refreshing dstFilename to srcFilename on touch.

  • UMD/nodejs templates:

    • fixed: 'module', 'export' being required from nodejs instead of referenced.

    • fixed: #22 & #8, #5 due to coffee-* helpers outside define() not taken into account.

  • 'combined' template has many new features, optimizations & bug fixes:

    • new: structure for globals/dependency injections, saving from having dependencies.exports.bundle injected in each Module. Exported deps are available in the closure enclosing the modules, reducing size.

    • new: AMD preDefineIFI statements are merged, saving space: the combined.js has only a single __extends, __slice etc from coffeescript, coco, Livescript etc, when AMD is used on source Modules in which case where the coffee-* compilers place these generated helpers outside the define(). Before 0.6, this was preventing using AMD with coffee or Livescript etc) because that code outside define() was not read. Now these helpers are merged into one to save space on the final combined.js!

    • fixed: factory() was a leak to global cause var was missing.

    • new: factory is passed globals as params

  • Various:

    • Many refactorings, bug fixes and improvements on NodeRequirer, Module, Bundle, AlmondTemplates, watching, error handling, reporting, partial building, Dependency resolution, @property is gone (was error prone), using CalcCachedProperties from uBerscore 0.13 & more.

0.5.0 - (2013-08-10)

A revamp of bundle: resources & Resource Converters - they are much more useful and stable as an in-memory conversion pipeline.

Breaking from 0.4.2 in ResourceConverter declarations :

  • ResourceConverter convert() is called with just the resource instance as 1st argument and context (value of this). The instance holds all sorts of useful information about its self.

  • Helpers copy, save & requireUncached are available on the resource instances (passed to convert()). Also added srcRealpath & dstRealpath for requireing nodejs modules without worrying about relative paths.

  • isTerminal:false as default (instead of true) - use "|" flag for true.

  • isModule flag is gone - now type handle all types of Resource Converters

  • dstFilename(filename) changed to convFilename(dstFilename, srcFilename). The resource still holds a dstFilename as the result of convFilename().

  • Can search for registered RCs by name on bundle:resources, either as a plain string or a function that has the search function as its context (this).

0.4.2 - (2013-07-07)

Just bug fixing

  • bundle.copy where it belongs, working with arrayizePusher.

  • dependencies bindings (eg dependencies.exports.bundle) derivation is much more robust.

0.4.1 - (2013-07-01)

  • bundle.resources converters now have an isAfterTemplate field - allows you to run code transformations either BEFORE (default) or after template has been applied to each Module.

  • Bug fixing & improved documentation.

0.4.0 - (2013-06-28)

Watching of builds is now an option:

  • builds only changed files

  • cache bundle & module info

  • quickest possible (re)conversion

  • suports partial builds & forces full build if needed (eg. 'combined' template)

Config format matures a lot (but still supports v0.3 fields as DEPRACATED):

  • bundle.filez works with minimatch (like grunt's files) & RegExps.

  • derivation is working properly & is documented better

More refactoring:

  • Better handling of resources: BundleFile <- UResource <- UModule

  • Improved error handling (UError, allowing nested errors & props) & debuging information.

  • config blending (derive) is cleaner

0.3.0

v0.3.0 was never released, but gave way to 0.4 :-)

Huge code revamp, can easily be used by other libraries (check urequireCMD.coffee & grunt-urequire).

Improved debugging / warning / informational handling and output.

combined template employing r.js & almond optimization

Configuration file with derivation appears.

0.2

Refactoring, code documentation, more spec tests, plan for incorporating future functionality.

AMD & nodejs only module tranlation, through respective (buildin) templates.

rootExports & noConflict() is declaratively offered.

Mimics the behaviour of RequireJS's require(['dep1', 'dep2'], function(){}) where if dependencies 'dep1' & 'dep2' are already loaded (i.e cached), the factory function is called synchronously (immediatelly). UPDATE: this feature is muted, to match RequireJS 2.1.x behaviour that fixed this.

v0.1.5 - v0.1.9

Working towards refactoring & loaderPlugins - node!, text! & json! are worked out (preliminary).

Support for native RequireJS loader plugins (like text! and json!).

v0.1.0 - Alpha/preview release

A preview of what uRequire aims to become. Quite usefull as it is, but still a non-stable/Alpha.