forked from novnc/noVNC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This changes around `utils/use_require.js` to be able to generate any of AMD (RequireJS), CommonJS, SystemJS, or UMD modules. The three former also include support for translating `vnc.html`, producing a full "app" version of noVNC.
- Loading branch information
1 parent
4faaf43
commit 6cae7b5
Showing
4 changed files
with
143 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// writes helpers require for vnc.html (they should output app.js) | ||
var fs = require('fs'); | ||
var fse = require('fs-extra'); | ||
var path = require('path'); | ||
|
||
module.exports = { | ||
'amd': { | ||
appWriter: (base_out_path, out_path) => { | ||
// setup for requirejs | ||
fs.writeFile(out_path, 'requirejs(["app/ui"], function (ui) {});', (err) => { if (err) throw err; }); | ||
console.log(`Please place RequireJS in ${path.join(base_out_path, 'require.js')}`); | ||
return `<script src="require.js" data-main="${path.relative(base_out_path, out_path)}"></script>`; | ||
}, | ||
}, | ||
'commonjs': { | ||
optionsOverride: (opts) => { | ||
// CommonJS supports properly shifting the default export to work as normal | ||
opts.plugins.unshift("add-module-exports"); | ||
}, | ||
appWriter: (base_out_path, out_path) => { | ||
var browserify = require('browserify'); | ||
var b = browserify(path.join(base_out_path, 'app/ui.js'), {}); | ||
b.bundle().pipe(fs.createWriteStream(out_path)); | ||
return `<script src="${path.relative(base_out_path, out_path)}"></script>`; | ||
}, | ||
}, | ||
'systemjs': { | ||
appWriter: (base_out_path, out_path) => { | ||
fs.writeFile(out_path, 'SystemJS.import("./app/ui.js");', (err) => { if (err) throw err; }); | ||
console.log(`Please place SystemJS in ${path.join(base_out_path, 'system-production.js')}`); | ||
return `<script src="system-production.js"></script>\n<script src="${path.relative(base_out_path, out_path)}"></script>`; | ||
}, | ||
}, | ||
'umd': { | ||
optionsOverride: (opts) => { | ||
// umd supports properly shifting the default export to work as normal | ||
opts.plugins.unshift("add-module-exports"); | ||
}, | ||
}, | ||
} |