Comments (7)
If you are using the RequireJS optimizer Grunt task, then it is very easy to integrate amdclean using the onBuildWrite
config option. Here is an example Grunt file that includes the RequireJS optimizer plugin with amdclean support:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
requirejs: {
js: {
options: {
findNestedDependencies: true,
baseUrl: 'src/js/app/modules',
wrap: true,
preserveLicenseComments: false,
optimize: 'none',
mainConfigFile: 'src/js/app/config/config.js',
include: ['first'],
out: 'src/js/app/exampleLib.js',
onBuildWrite: function( name, path, contents ) {
return require('amdclean').clean(contents);
}
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.registerTask('build', ['requirejs:js']);
grunt.registerTask('default', ['build']);
};
from amdclean.
Cool, thx for the fast response. You might want to add that in the README for others.
Anyway, it is still not working for me. With the grunt config of mine I get an error:
$ grunt requirejs
Running "requirejs:js" (requirejs) task
>> Tracing dependencies for: main
[Error: Error: Error: Not a unique module name: jade
Fix: Make sure that you assign unique module paths using the require.config() method. Take a look at http://requirejs.org/docs/api.html#config for more details
Result: Did not complete and exiting...
at Object.utils.hasUniqueModuleName (/xxx/node_modules/amdclean/src/amdclean.js:90:35)
]
Here is my config, inspired by you:
requirejs: {
js: {
options: {
findNestedDependencies: true,
baseUrl: "client/scripts",
name: 'main',
mainConfigFile: "client/scripts/config/require.config.js",
out: "server/public/scripts/main.min.js",
useStrict: true,
preserveLicenseComments: false,
optimize: 'uglify2',
pragmasOnSave: {
excludeJade : true // remove jade compiler, se https://github.com/deedubs/require-jade
},
onBuildWrite: function( name, path, contents ) {
return require('amdclean').clean(contents);
}
}
}
In my require.config.js I have declared the path for jade and it works fine.
from amdclean.
Good call with adding the Grunt information to the README, I'll add it tonight. That error message says that you have more than one module with the same name. Could you send the full source of your library un-minified (just comment out the amdclean for now).
from amdclean.
Ok, have sent the source code to your inbox. Do not want to publish it. Hope you can find the problem?
from amdclean.
Okay, so jade is declared twice:
define('jade', jade);
define('jade',{
version: '0.0.3',
load: function (name, parentRequire, load, config) {
}
});
Also, amdclean doesn't support AMD module loader plugins. I think almond.js would be a better fit for your use case.
from amdclean.
Oh I see. Thanks a lot for your honesty and help. Great response.
All the best!
from amdclean.
@binarykitchen AMDClean is now a much more mature project and should work for you.
from amdclean.
Related Issues (20)
- Module config HOT 1
- source-map: sourcesContent lost HOT 1
- does amdclean support amd-feature loader plugin
- AMD checks transformations HOT 1
- Problems with "module" special dependency HOT 3
- require with named callback -- the callback is never called HOT 1
- bin/amdclean HOT 1
- AMD destroys multiline return statements HOT 3
- The variable conflict logic in v2.4.0 and onwards HOT 2
- var a = require('a') => var a = a;
- Bad output
- Deal with conditional loader HOT 1
- A comment in return statement leads to incorrect javascript
- function of the calling module goes before the called module: Cannot read property of undefined HOT 1
- Failed to require relative path
- UMD generated by rollup not recognized HOT 1
- define(modulename, dependencies...
- Bug: aggressiveOptimizations may shadow globals
- Comma-separated calls to define don't get translated HOT 1
- npmjs release update
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amdclean.