Destealify
Browserify transform for processing StealJS modules
Install / Use
/learn @zkat/DestealifyREADME
destealify
destealify is a browserify transform that allows free intermixing of StealJS modules with Node.js-style CommonJS modules.
It also supports webpack. See
examples/canjs-webpack.
Quickstart
Install
$ npm install destealify
Examples
Command Line
browserify -t destealify main.js -o bundle.js
API
var browserify = require('browserify');
var fs = require('fs');
var b = browserify('main.js');
b.transform('destealify');
b.bundle().pipe(fs.createWriteStream('bundle.js'));
package.json
For packages that are written as StealJS modules, add a browserify
transform field to package.json and browserify will apply the transform
to all modules in the package as it builds a bundle.
{
"name": "anchor",
"main": "main",
"browserify": {
"transform": "destealify"
}
}
CanJS
Unfortunately, there's no obvious way to use browserify directly with the
steal version of CanJS. This is because browserify does
not recursively transform dependencies, and expects them to do their own
transformation, or use the browserify field -- which would then need further
configuration for the quirks of how the CanJS repo works.
Instead, use webpack, which has a similar
featureset to browserify. See examples/canjs-webpack for details.
stealconfig.js
Most StealJS modules rely on absolute pathing. There are two ways around this:
- use symlinks in
node_modules/to arrange your paths such thatrequire()works as expected for the paths in the steal module. - Use a
stealconfig.jsfile in a parent directory of your module and use themapandpathsoptions, which are handled by this transform, to map module names as needed.
For example, if you have a module that looks like:
steal("frob/this", function() {
});
destealify will first translate that dependency to "frob/this/this.js",
following StealJS conventions.
If your this.js library is located in
./bower_components/frobjs/this/index.js, you can write a stealconfig.js in
your project's root that looks like:
steal.config({
map: {
"*": {
"frob/this/this.js": "thisjs"
}
},
paths: {
"thisjs": "bower_components/frobjs/this"
}
});
and everything will be taken care of for you.
License
destealify is a public domain work, dedicated using
CC0 1.0. Feel free to do
whatever you want with it.
Related Skills
node-connect
350.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
