mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-30 12:11:32 +08:00
Add script to amd-ify the commonjs code,
(backwards compat. and dynamic loading)
This commit is contained in:
parent
4c07a8bffc
commit
a719e19b39
13
.gitignore
vendored
13
.gitignore
vendored
@ -29,12 +29,13 @@ src
|
|||||||
.eggs/
|
.eggs/
|
||||||
|
|
||||||
# Bundled/generated JavaScript
|
# Bundled/generated JavaScript
|
||||||
notebook/static/auth/js/main.bundle.js
|
notebook/static/auth/js
|
||||||
notebook/static/edit/js/main.bundle.js
|
notebook/static/base/js
|
||||||
notebook/static/notebook/js/main.bundle.js
|
notebook/static/edit/js
|
||||||
notebook/static/services/contents.bundle.js
|
notebook/static/notebook/js
|
||||||
notebook/static/terminal/js/main.bundle.js
|
notebook/static/services
|
||||||
notebook/static/tree/js/main.bundle.js
|
notebook/static/terminal/js
|
||||||
|
notebook/static/tree/js
|
||||||
|
|
||||||
# npm logs
|
# npm logs
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
30
notebook/amd.js
Normal file
30
notebook/amd.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
var amdWrap = require("amd-wrap-legacy");
|
||||||
|
var glob = require("glob");
|
||||||
|
var path = require('path');
|
||||||
|
var fs = require('fs');
|
||||||
|
var mkdirp = require("mkdirp");
|
||||||
|
|
||||||
|
var source = "./notebook/static-src";
|
||||||
|
var destination = "./notebook/static";
|
||||||
|
|
||||||
|
glob(path.join(source, "**/*.js"), function(err, files) {
|
||||||
|
if (err) {
|
||||||
|
console.error('Could not glob files.', err);
|
||||||
|
} else {
|
||||||
|
files.forEach(function(file, index) {
|
||||||
|
var toFile = path.join(destination, path.relative(source, file));
|
||||||
|
fs.readFile(file, 'utf8', function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.error('Could not read file ' + file, err);
|
||||||
|
} else {
|
||||||
|
mkdirp(path.dirname(toFile), function(err) { if (err) {console.error('Could not mkdirp ', err);} });
|
||||||
|
fs.writeFile(toFile, amdWrap(data), function(err) {
|
||||||
|
if(err) {
|
||||||
|
return console.error('Could not write file ' + toFile, err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
@ -1,66 +1,33 @@
|
|||||||
if (process.argv.length >= 4) {
|
var fs = require('fs');
|
||||||
var fs = require('fs');
|
var aliasify = require('aliasify');
|
||||||
var aliasify = require('aliasify');
|
var browserify = require('browserify');
|
||||||
var browserify = require('browserify');
|
|
||||||
|
|
||||||
var aliasifyConfig = {
|
var aliasifyConfig = {
|
||||||
aliases: {
|
aliases: {
|
||||||
// underscore : 'components/underscore/underscore-min',
|
// underscore : 'components/underscore/underscore-min',
|
||||||
// backbone : 'components/backbone/backbone-min',
|
// backbone : 'components/backbone/backbone-min',
|
||||||
// jquery: 'components/jquery/jquery.min',
|
// jquery: 'components/jquery/jquery.min',
|
||||||
bootstrap: 'components/bootstrap/js/bootstrap.min',
|
bootstrap: 'components/bootstrap/js/bootstrap.min',
|
||||||
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
|
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
|
||||||
// jqueryui: 'components/jquery-ui/ui/minified/jquery-ui.min',
|
// jqueryui: 'components/jquery-ui/ui/minified/jquery-ui.min',
|
||||||
// moment: 'components/moment/moment',
|
// moment: 'components/moment/moment',
|
||||||
// codemirror: 'components/codemirror',
|
// codemirror: 'components/codemirror',
|
||||||
// termjs: 'components/term.js/src/term'
|
// termjs: 'components/term.js/src/term'
|
||||||
|
|
||||||
jqueryui: 'jquery-ui',
|
jqueryui: 'jquery-ui',
|
||||||
termjs: 'term.js'
|
termjs: 'term.js'
|
||||||
},
|
},
|
||||||
verbose: false
|
verbose: false
|
||||||
}
|
|
||||||
|
|
||||||
var b = browserify({
|
|
||||||
paths: [
|
|
||||||
__dirname + '/static',
|
|
||||||
],
|
|
||||||
debug: true,
|
|
||||||
fullPaths: true
|
|
||||||
});
|
|
||||||
|
|
||||||
b.transform(aliasify, aliasifyConfig);
|
|
||||||
b.add(__dirname + '/static/' + process.argv[2]);
|
|
||||||
b.bundle().pipe(fs.createWriteStream(__dirname + '/static/' + process.argv[3]));
|
|
||||||
} else {
|
|
||||||
|
|
||||||
var amdWrap = require("amd-wrap-legacy");
|
|
||||||
var glob = require("glob");
|
|
||||||
var path = require('path');
|
|
||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
var source = "./notebook/static-src";
|
|
||||||
var destination = "./notebook/static";
|
|
||||||
|
|
||||||
glob(path.join(source, "**/*.js"), function(err, files) {
|
|
||||||
if (err) {
|
|
||||||
console.error('Could not glob files.', err);
|
|
||||||
} else {
|
|
||||||
files.forEach(function(file, index) {
|
|
||||||
var toFile = path.join(destination, path.relative(source, file));
|
|
||||||
fs.readFile(file, 'utf8', function (err, data) {
|
|
||||||
if (err) {
|
|
||||||
console.error('Could not read file ' + file, err);
|
|
||||||
} else {
|
|
||||||
fs.writeFile(toFile, amdWrap(data), function(err) {
|
|
||||||
if(err) {
|
|
||||||
return console.error('Could not write file ' + toFile, err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// var wrapped = amdWrap("module.exports = 5;");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var b = browserify({
|
||||||
|
paths: [
|
||||||
|
__dirname + '/static-src',
|
||||||
|
],
|
||||||
|
debug: true,
|
||||||
|
fullPaths: true
|
||||||
|
});
|
||||||
|
|
||||||
|
b.transform(aliasify, aliasifyConfig);
|
||||||
|
b.add(__dirname + '/static-src/' + process.argv[2]);
|
||||||
|
b.bundle().pipe(fs.createWriteStream(__dirname + '/static/' + process.argv[3]));
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"build:css:ipython": "lessc --source-map --include-path=./notebook/static/ ./notebook/static/style/ipython.less ./notebook/static/style/ipython.min.css",
|
"build:css:ipython": "lessc --source-map --include-path=./notebook/static/ ./notebook/static/style/ipython.less ./notebook/static/style/ipython.min.css",
|
||||||
"build:css:style": "lessc --source-map --include-path=./notebook/static/ ./notebook/static/style/style.less ./notebook/static/style/style.min.css",
|
"build:css:style": "lessc --source-map --include-path=./notebook/static/ ./notebook/static/style/style.less ./notebook/static/style/style.min.css",
|
||||||
"build:js": "concurrent \"npm run build:js:amd\" \"npm run build:js:tree\" \"npm run build:js:terminal\" \"npm run build:js:notebook\" \"npm run build:js:edit\" \"npm run build:js:auth\" \"npm run build:js:contents\"",
|
"build:js": "concurrent \"npm run build:js:amd\" \"npm run build:js:tree\" \"npm run build:js:terminal\" \"npm run build:js:notebook\" \"npm run build:js:edit\" \"npm run build:js:auth\" \"npm run build:js:contents\"",
|
||||||
"build:amd": "node ./notebook/build.js",
|
"build:js:amd": "node ./notebook/amd.js",
|
||||||
"build:js:notebook": "node ./notebook/build.js notebook/js/main.js notebook/js/main.bundle.js",
|
"build:js:notebook": "node ./notebook/build.js notebook/js/main.js notebook/js/main.bundle.js",
|
||||||
"build:js:contents": "node ./notebook/build.js services/contents.js services/contents.bundle.js",
|
"build:js:contents": "node ./notebook/build.js services/contents.js services/contents.bundle.js",
|
||||||
"build:js:edit": "node ./notebook/build.js edit/js/main.js edit/js/main.bundle.js",
|
"build:js:edit": "node ./notebook/build.js edit/js/main.js edit/js/main.bundle.js",
|
||||||
@ -39,6 +39,7 @@
|
|||||||
"jquery-ui": "~1.10",
|
"jquery-ui": "~1.10",
|
||||||
"less": "~2",
|
"less": "~2",
|
||||||
"marked": "~0.3",
|
"marked": "~0.3",
|
||||||
|
"mkdirp": "^0.5.1",
|
||||||
"moment": "~2.8.4",
|
"moment": "~2.8.4",
|
||||||
"rimraf": "^2.4.2",
|
"rimraf": "^2.4.2",
|
||||||
"term.js": "~0.0.4",
|
"term.js": "~0.0.4",
|
||||||
|
@ -114,12 +114,12 @@ def find_package_data():
|
|||||||
# so that installation will fail if they are missing
|
# so that installation will fail if they are missing
|
||||||
for app in ['auth', 'edit', 'notebook', 'terminal', 'tree']:
|
for app in ['auth', 'edit', 'notebook', 'terminal', 'tree']:
|
||||||
static_data.append(pjoin('static', app, 'js', 'main.bundle.js'))
|
static_data.append(pjoin('static', app, 'js', 'main.bundle.js'))
|
||||||
|
static_data.append(pjoin('static', 'services', 'contents.bundle.js'))
|
||||||
|
|
||||||
components = pjoin("static", "components")
|
components = pjoin("static", "components")
|
||||||
# select the components we actually need to install
|
# select the components we actually need to install
|
||||||
# (there are lots of resources we bundle for sdist-reasons that we don't actually use)
|
# (there are lots of resources we bundle for sdist-reasons that we don't actually use)
|
||||||
static_data.extend([
|
static_data.extend([
|
||||||
pjoin(components, "backbone", "backbone-min.js"),
|
|
||||||
pjoin(components, "bootstrap", "js", "bootstrap.min.js"),
|
pjoin(components, "bootstrap", "js", "bootstrap.min.js"),
|
||||||
pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"),
|
pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"),
|
||||||
pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"),
|
pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"),
|
||||||
@ -130,13 +130,7 @@ def find_package_data():
|
|||||||
pjoin(components, "jquery-ui", "ui", "minified", "jquery-ui.min.js"),
|
pjoin(components, "jquery-ui", "ui", "minified", "jquery-ui.min.js"),
|
||||||
pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"),
|
pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"),
|
||||||
pjoin(components, "jquery-ui", "themes", "smoothness", "images", "*"),
|
pjoin(components, "jquery-ui", "themes", "smoothness", "images", "*"),
|
||||||
pjoin(components, "marked", "lib", "marked.js"),
|
|
||||||
pjoin(components, "requirejs", "require.js"),
|
pjoin(components, "requirejs", "require.js"),
|
||||||
pjoin(components, "underscore", "underscore-min.js"),
|
|
||||||
pjoin(components, "moment", "moment.js"),
|
|
||||||
pjoin(components, "moment", "min", "moment.min.js"),
|
|
||||||
pjoin(components, "term.js", "src", "term.js"),
|
|
||||||
pjoin(components, "text-encoding", "lib", "encoding.js"),
|
|
||||||
])
|
])
|
||||||
|
|
||||||
# Ship all of Codemirror's CSS and JS
|
# Ship all of Codemirror's CSS and JS
|
||||||
|
Loading…
Reference in New Issue
Block a user