
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A port of ImportJS for node. Enables a packaging system for JavaScript classes, similar to that of Java or ActionScript 3.
(For the original library and complete usage instructions, please see: https://github.com/Cleod9/importjs)
This library is a Node.js port of ImportJS that allows you to use the same module-loading features offered by ImportJS on the filesystem. The only difference between the browser and Node version is that you must define your modules slightly differently. See below for details.
npm install importjs
And that's it! You can then start using it by simply requiring the importjs module:
var ImportJS = require('importjs');
You will then have access to the library through the variable ImportJS.
See below for a quick example:
//Load modules dynamically through the filesystem
ImportJS.preload({
baseUrl: '',
files: {
tests: {
Sample: 'Sample.js', //<- File ./tests/Sample.js will be loaded into ImportJS
}
},
ready: function(files) {
//At this point your modules are good to go, you could use this as an entry point for your application
var Sample = ImportJS.unpack('tests.Sample');
var mySample = new Sample();
}
});
//Or define modules explicitly at your leisure, unpack when needed.
ImportJS.pack('com.project.MyClass', function(module, exports) {
function MyClass() {
};
//Just like Node, you can set your exports via 'module.exports' and/or 'exports'
module.exports = MyClass;
});
var MyClass = ImportJS.unpack('com.project.MyClass');
var me = new MyClass();
So just like the browser version, you have the option of loading up files dynamically into ImportJS via the preload() function, or just defining them across an arbitrary number of files.
When dynamically preloading modules via the preload() function, you simply make sure that these other files also contain the require('importjs')' at the top. (Alternatively you could assign it to global.ImportJS if you'd like instead)
var ImportJS = require('importjs');
/* Follow same syntax as browser version of ImportJS */
ImportJS.pack('tests.Sample', function (module) {
//Module "CodeFile" is included without require() thanks to ImportJS
var CodeFile = this.import('some.other.CodeFile');
this.inject(function() {
//If you have circular deps, import them here to hoist them up
});
function Sample() {
var foo = 'I am a Sample class';
this.value = function() {
return foo;
}
};
//Exposes your 'exported' variable
module.exports = Sample;
});
As you can see, this is exactly how you would write code for this library with the browser version (except for the require() of course). One thing to note however, is that you only need to touch ImportJS's rendition of module.exports to store your module. All of your packaged code files can communicate with one another explicitly through ImportJS. In other words, instead of using require() to retrieve your packaged modules within ImportJS's scope, you can simply load them via this.import('path.to.module').
For the detailed instructions on this library's features, see the test file included in this repo, as well as the docs for the original ImportJS.
Aside: This library also works great with OOPS.js for Node!
3.0.0
module.postCompile and added this.inject which accepts a single functionthis.import to replace the use of ImportJS global from within modulesCopyrighted © 2015 by Greg McLeod
GitHub: https://github.com/cleod9
FAQs
A port of ImportJS for node. Enables a packaging system for JavaScript classes, similar to that of Java or ActionScript 3.
The npm package importjs receives a total of 50 weekly downloads. As such, importjs popularity was classified as not popular.
We found that importjs 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.