aearly / grunt-urequire Goto Github PK
View Code? Open in Web Editor NEWGrunt wrapper for uRequire
Grunt wrapper for uRequire
Hi!
I have two AMD modules, A & B, which I'm trying to convert using UMD template so that they either available as AMD, CommonJS & available in global using rootExports
.
So, for example, I'm including that fragment in the configuration:
rootExports: ["A"],
noRootExports: false // which isn't supposed to be required based on what I've read
But I'm getting the following:
(function (factory) {
if (typeof exports === 'object') {
var nr = new (require('urequire').NodeRequirer) ('A', module, __dirname, '.');
module.exports = factory(nr.require, exports, module);
} else if (typeof define === 'function' && define.amd) {
define(factory);
}
}).call(this, function (require, exports, module) {
I thought I should have gotten an additional else
block like:
else {
global.A = factory();
}
There should be something I'm getting wrong. Any idea?
I am the author of uRequire - thanks for the grunt plugin!
The next version 0.3 will pose a new bundle & build config file, bundle-global dependencies (eg. saving you from having to require 'lodash' in every module of your bundle) & most important of all a single-file optimized almond-based 3-fold build:
In all cases, globals are NOT inlined, but are used from window
, AMD paths or node require
respectively.
Hope you update when time comes - watch the commits and thanks again!
Hi - I have finally committed (an alpha) version of the completely revamped uRequire v0.3 - still no detailed docs, but they 're on the the way...
I 've made all required changes in grunt-require and all tests pass. The format has changed, but its still backwards compatible, only deprecated.
Could you please publish grunt-require (and allow me to npm publish
it as well if you can!)
Regards
PS: Alexander please excuse my coffeescript, but I cant bare to write standard .js these days!
I have the following structure of source files:
- source/
- library/
- C.js
- D.js
- A.js
- B.js
Let's say B
depends on A
which in turn requires C
and D
. When developing I use RequireJS and some configuration block like:
require.config({
baseUrl: "/source",
paths: {
"C": "library/C",
"D": "library/D"
}
});
I'm willing to have A
& B
or whatever other module that requires lodash
and/or EventEmitter
find them in the global scope when running the standalone, combined version of the project. Here's the uRequire Grunt configuration block I'm using:
standalone: {
template: "combined",
path: "source",
filez: [
"library/*.js",
"*.js"
],
//*
dependencies: {
exports: {
bundle: {
"lodash": "_",
"EventEmitter": "EventEmitter2"
}
}
},
//*/
dstPath: "distribution/Z-standalone.js"
What's problematic, and I may be missing something obvious, is C
& D
don't seem to be included in the bundle, even with filez
containing those. I'm getting the following error:
Uncaught Error: uRequire detected missing dependency: 'C' - in a non-nodejs runtime. All it's binding variables were 'undefined'.
Having a look at Z-standalone.js
I' reading things like (which are pretty close to what's done for global dependencies):
define('C',[],function () {
if (__isNode) {
return __nodeRequire('C');
} else {
return (typeof C !== 'undefined') ? C : __nodeRequire('C')
}
});
How does it sound to you?
Hey there, so uberscore
was added as a devDependency in this commit. But it's also being used in the task here. Since it's just a devDependency, it doesn't get installed for someone using it in like a package.json file. I suppose it could be just put into "dependencies" and solve this.
I'm posting this issue to let you know that we will be publishing Grunt 0.4 on Monday, February 18th.
If your plugin is not already Grunt 0.4 compatible, would you please consider updating it? For an overview of what's changed, please see our migration guide.
If you'd like to develop against the final version of Grunt before Monday, please specify "grunt": "0.4.0rc8"
as a devDependency in your project. After Monday's release, you'll be able to use "grunt": "~0.4.0"
to actually publish your plugin. If you depend on any plugins from the grunt-contrib series, please see our list of release candidates for compatible versions. All of these will be updated to final status when Grunt 0.4 is published.
Also, in an effort to reduce duplication of effort and fragmentation in the developer community, could you review the grunt-contrib series of plugins to see if any of your functionality overlaps significantly with them? Grunt-contrib is community maintained with 40+ contributors—we'd love to discuss any additions you'd like to make.
Finally, we're working on a new task format that doesn't depend on Grunt: it's called node-task. Once this is complete, there will be one more conversion, and then we'll never ask you to upgrade your plugins to support our changes again. Until that happens, thanks for bearing with us!
If you have any questions about how to proceed, please respond here, or join us in #grunt on irc.freenode.net.
Thanks, we really appreciate your work!
While using UMD
default template the following configuration produces a "XML.js" file into "distribution" folder, which is what I expected. But using the combined
template it produces a "distribution.js" file at the root of my project. If I want it to produce the same thing as in the first case I need to append "/XML.js" to the dstPath
property. Is that normal?
urequire: {
XML: {
// template: "combined",
path: "source",
filez: "XML.js",
main: "XML",
dstPath: "distribution",
rootExports: "XML"
}
}
There is no urequire 0.7.0 version available. The latest is 0.7.0.beta.10
$ npm install grunt-urequire
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "grunt-urequire"
npm ERR! node v0.10.34
npm ERR! npm v2.1.14
npm ERR! code ETARGET
npm ERR! notarget No compatible version found: urequire@'>=0.7.0 <0.8.0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.0.8","0.1.4","0.1.5","0.1.6","0.2.5","0.2.7","0.2.8","0.2.9","0.2.9-2","0.2.9-3","0.4.0","0.4.1","0.4.2","0.5.0","0.3.0-alpha15","0.3.0-alpha17","0.3.0-alpha18","0.3.0-alpha19","0.3.0-alpha20","0.3.0-alpha21","0.3.0-alpha22","0.3.0-beta1","0.3.0-beta2","0.6.0","0.6.0-1","0.6.1","0.6.2","0.6.2-1","0.6.3","0.6.4","0.6.5","0.6.6","0.6.7","0.6.8","0.6.9","0.6.10","0.6.11","0.6.12","0.6.13-1","0.6.14","0.6.15","0.6.18","0.6.19","0.6.20","0.7.0-beta1","0.7.0-beta2","0.7.0-beta3","0.7.0-beta4","0.7.0-beta6","0.7.0-beta7","0.7.0-beta8","0.7.0-beta9","0.7.0-beta10","0.7.0-beta.11","0.7.0-beta.12","0.7.0-beta.13","0.7.0-beta.14"]
npm ERR! notarget
I have in my files
urequire:
convert:
path: 'src/app/'
dstPath: 'temp/app/'
main: 'main'
_defaults:
debugLevel: 100
verbose: true
scanAllow: true
allNodeRequires: true
noRootExports: false
grunt.registerTask 'server', [
'clean:temp'
'script'
require.config
paths:
depend: 'vendor/require-depend'
underscore: 'components/lodash'
jquery: 'components/jquery'
chaplin: '../components/scripts/chaplin/chaplin'
marked: '../components/scripts/marked/marked'
require ['application', 'routes'], (Application, routes) ->
new Application {
title: 'Combats',
controllerSuffix: '-controller',
routes
}
<script src="/components/scripts/requirejs/require.js"
data-main="/app/main"></script>
Should I use require.js and should I ignore main.coffee on urequire:convert task ?
Can you help me how can I run app ?
How can I generate coffee source maps ?
Grunt config
urequire:
convert:
path: 'src/app/'
dstPath: 'temp/app/'
main: 'main'
filez: ['**/*.*', '!main.coffee', '!vendor/**/*.*']
_defaults:
debugLevel: 0
verbose: true
scanAllow: true
allNodeRequires: true
noRootExports: false
I think I might be doing something stupid, but I can't for the life of me figure out how to inject a comment banner into the final compiled output of my urequire tasks.
Here is my urequire config:
urequire: {
dev: {
template: 'combined',
path: '<%= dirs.src %>',
dstPath: '<%= files.dev %>',
main: '<%= files.main %>'
},
dist: {
template: 'combined',
path: '<%= dirs.src %>',
dstPath: '<%= files.dist %>',
main: '<%= files.main %>',
optimize: true
},
_defaults: {
build: {
debugLevel: 0,
verbose: false,
scanAllow: true,
allNodeRequires: true,
noRootExports: false
},
dependencies: {
exports: {
root: {
'core': ['gf']
}
}
},
bundle: {
resources: [
['!#inject:BANNER', ['<%= files.dist %>'], function(m) {
return banner + m.read();
}]
]
}
}
},
I have tried using +inject:BANNER
as well as changing my filez to ['**/gf.min.js']
in case it didn't expand ('<%= files.dist %>'
should expand to 'build/gf.min.js'
). I have tried changing this to use m.beforeBody = banner;
etc and just about any example I could find and none of them work; each time I only see the almond banner (which I would like to remove btw, is there a setting for that?).
Any help is greatly appreciated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.