
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.
DefineJS is an Asynchronous Module Definition wrapper for Node. Writing modules in AMD style is convenient when code is shared between Node and a browser. The client needs to use an AMD loader like RequireJS.
Add a dependency to your project's package.json and run npm install:
{
"dependencies" {
"define": "1.0"
}
}
or install manually:
npm install define
In your app's main script:
require('define');
This will add define as a global so it's available everywhere else
in the application automatically. Create AMD modules anywhere you
like. They can be loaded with require or define.
See examples/shared-code for a working example web server.
require('define') in every AMD module.DefineJS installs define as a global when it's loaded. The makes
define available everywhere else in the application without any
special workarounds in each file.
If you don't want a global definition, do the following in your app's main script:
require('define').noConflict();
then, for individual modules that need define:
if (typeof define === 'undefined') {
var define = require('define');
}
However, if you prefer this approach and you're using RequireJS for the client-side loader anyway, you should probably just use the similar amdefine convention because the RequireJS optimizer strips it away.
The AMD Spec allows module definitions to optionally specify an id. This is very helpful for transport when several modules are concatenated into the same file.
DefineJS currently accepts module ids, but ignores them. This is
because it's just a very light wrapper around Node's require. Node
uses a module's absolute filename as the id, so defining more than one
module in a file is currently unsupported.
In practice, this doesn't matter very much. Just follow the one-module-to-one-file convention and use something like the RequireJS Optimizer for client-side code in production.
Refer to the AMD Wiki for more information about AMD.
FAQs
An AMD wrapper for Node modules
The npm package define receives a total of 9,282 weekly downloads. As such, define popularity was classified as popular.
We found that define 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.