![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
grunt-concat-in-order
Advanced tools
Concatenates files respecting declared, required dependencies order.
Concatenates files respecting dependencies.
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-concat-in-order --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-concat-in-order');
The concat_in_order
task extracts declared required dependencies as well as provided modules/classes from your javascript (or any other text) files. Having this dependency graph the task will perform topological sort and concatenate file so that all modules will be put after their required dependencies.
In your project's Gruntfile, add a section named concat_in_order
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
concat_in_order: {
your_target: {
options: {
/*
this is the default banner prepended to the resulting file
banner: '',
this is a default function that extracts required dependencies/module names from file content
(getMatches - function that pick groups from given regexp)
extractRequired: function (filepath, filecontent) {
return this.getMatches(/require\(['"]([^'"]+)['"]/g, filecontent);
},
this is a default function that extracts declared modules names from file content
extractDeclared: function (filepath, filecontent) {
return this.getMatches(/declare\(['"]([^'"]+)['"]/g, filecontent);
}
*/
},
files: {
'build/concatenated.js': ['lib/**/*.js']
}
}
}
})
Let's say you have 4 files in a lib
directory
/*start AUsingBaseBAndBaseA*/
framwork.require('module.BaseB');
framwork.require('module.BaseA');
framework.declare('module.UsingBaseBAndBaseA');
var forth = function fourthFunction(){};
/*end AUsingBaseBAnddBaseA*/
/*start AUsingBaseA*/
framwork.require('module.BaseA');
var second = function secondFunction(){};
/*end AUsingBaseA*/
/*start BaseA*/
framework.declare('module.BaseA');
var first = function firstFunction(){};
/*end BaseA*/
/*start BaseBUsingBaseA*/
framwork.require('module.BaseA');
framework.declare('module.BaseBUsingBaseA');
framework.declare('module.BaseB');
var third = function thirdFunction(){};
/*end BaseBUsingBaseA*/
Given the above configuration the task will produce build/concatenated.js
file with following content:
/*start BaseA*/
framework.declare('module.BaseA');
var first = function firstFunction(){};
/*end BaseA*/
/*start BaseBUsingBaseA*/
framwork.require('module.BaseA');
framework.declare('module.BaseBUsingBaseA');
framework.declare('module.BaseB');
var third = function thirdFunction(){};
/*end BaseBUsingBaseA*/
/*start AUsingBaseA*/
framwork.require('module.BaseA');
var second = function secondFunction(){};
/*end AUsingBaseA*/
/*start AUsingBaseBAndBaseA*/
framwork.require('module.BaseB');
framwork.require('module.BaseA');
framework.declare('module.UsingBaseBAndBaseA');
var forth = function fourthFunction(){};
/*end AUsingBaseBAnddBaseA*/
You can enable automatic addition of files with the following example. (notice the onlyConcatRequiredFiles : true) This is the same way of declaring dependencies used by juicer
files: {
'dist/mybuild.js': ['js/src/main.js']
},
options: {
extractRequired: function(filepath, filecontent) {
var workingdir = path.normalize(filepath).split(path.sep);
workingdir.pop();
var deps = this.getMatches(/\*\s*@depend\s(.*\.js)/g, filecontent);
deps.forEach(function(dep, i) {
var dependency = workingdir.concat([dep]);
deps[i] = path.join.apply(null, dependency);
});
return deps;
},
extractDeclared: function(filepath) {
return [filepath];
},
onlyConcatRequiredFiles: true
}
This will declare all files as modules using their filenames. In main.js you will typically have these depend statements:
/**
* @depend ../lib/jquery.js
* @depend otherfile.js
* @depend calculator/add.js
*/
You only need to specify the main.js and the other dependencies will be added automatically. As well as their dependencies etc.
If you want to add a file that isn't referenced anywhere you need to add it manually.
files: {
'dist/mybuild.js': ['js/src/main.js', 'js/src/unReferencedButWanted.js']
},
The option onlyConcatRequiredFiles will only work if modules are declared and required with their actual filenames.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
FAQs
Concatenates files respecting declared, required dependencies order.
The npm package grunt-concat-in-order receives a total of 86 weekly downloads. As such, grunt-concat-in-order popularity was classified as not popular.
We found that grunt-concat-in-order 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
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.