From 899ec1d3604937c25366ab3015cfec28f1d291fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 27 Jun 2013 14:31:03 -0700 Subject: [PATCH] Make built version of paper.js for node work and work towards using that in NPM. --- build/build.sh | 2 +- package.json | 11 +++++++++-- src/core/PaperScript.js | 10 ++++++---- src/export.js | 3 +++ src/load.js | 2 -- src/paper.js | 2 +- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/build/build.sh b/build/build.sh index 20ae22bb..e4bdc535 100755 --- a/build/build.sh +++ b/build/build.sh @@ -32,7 +32,7 @@ fi ./preprocess.sh $MODE ../src/paper.js "-o '{ \"browser\": true }' -i '../src/constants.js'" ../dist/paper-full.js ./preprocess.sh $MODE ../src/paper.js "-o '{ \"browser\": true, \"paperscript\": false }' -i '../src/constants.js'" ../dist/paper-core.js -#./preprocess.sh $MODE ../src/paper.js "-o '{ \"node\": true }' -i '../src/constants.js'" ../dist/paper-node.js +./preprocess.sh $MODE ../src/paper.js "-o '{ \"browser\": false, \"node\": true }' -i '../src/constants.js'" ../dist/paper-node.js # Remove the existing file and copy paper-full.js to paper.js now if [ -f ../dist/paper.js ] diff --git a/package.json b/package.json index 4cf346fd..966568a6 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,14 @@ "Jürg Lehni (http://lehni.org)", "Jonathan Puckey (http://studiomoniker.com)" ], - "main": "./src/load.js", + "main": "./dist/paper-node.js", + "files": [ + "AUTHORS.md", + "dist/paper-node.js", + "examples/Node.js", + "LICENSE.txt", + "README.md" + ], "engines": { "node": ">= 0.4.0" }, @@ -29,7 +36,7 @@ ], "devDependencies": { "uglify-js": "~2.3.6", - "prepro": "~0.7.0", + "prepro": "~0.7.1", "grunt": "~0.4.1", "grunt-contrib-uglify": "~0.2.2" } diff --git a/src/core/PaperScript.js b/src/core/PaperScript.js index 697c32ac..aa9dd34f 100644 --- a/src/core/PaperScript.js +++ b/src/core/PaperScript.js @@ -19,10 +19,13 @@ // better minification and the future use of strict mode once it makes sense // in terms of performance. paper.PaperScope.prototype.PaperScript = new function() { + var PaperScope = paper.PaperScope, + // Locally turn of exporst for inlined acorn / esprima. + exports = undefined; /*#*/ if (options.parser == 'acorn') { -/*#*/ include('../../components/acorn/acorn.min.js'); +/*#*/ include('../../components/acorn/acorn.min.js', { exports: false }); /*#*/ } else if (options.parser == 'esprima') { -/*#*/ include('../../components/esprima/esprima.min.js'); +/*#*/ include('../../components/esprima/esprima.min.js', { exports: false }); /*#*/ } // Operators to overload @@ -273,8 +276,7 @@ paper.PaperScope.prototype.PaperScript = new function() { } function load() { - var scripts = document.getElementsByTagName('script'), - PaperScope = paper.PaperScope; + var scripts = document.getElementsByTagName('script'); for (var i = 0, l = scripts.length; i < l; i++) { var script = scripts[i]; // Only load this script if it not loaded already. diff --git a/src/export.js b/src/export.js index 98111c5b..9d359a0c 100644 --- a/src/export.js +++ b/src/export.js @@ -43,4 +43,7 @@ paper = new (PaperScope.inject(Base.merge(Base.exports, { Canvas: Canvas })))(); +// Export the paper scope. +module.exports = paper; + /*#*/ } // options.node diff --git a/src/load.js b/src/load.js index 5469d735..2a6d111a 100644 --- a/src/load.js +++ b/src/load.js @@ -48,6 +48,4 @@ if (typeof window !== 'undefined') { }); // Load Paper.js library files. prepro.include('paper.js'); - // Export the paper scope. - module.exports = prepro.context.paper; } diff --git a/src/paper.js b/src/paper.js index e6cababc..261f2021 100644 --- a/src/paper.js +++ b/src/paper.js @@ -32,7 +32,7 @@ var paper = new function() { // Inline Bootstrap core (the Base class) inside the paper scope first: -/*#*/ include('../components/straps/straps.js'); +/*#*/ include('../components/straps/straps.js', { exports: false }); /*#*/ if (options.stats) { /*#*/ include('../components/stats.js/build/stats.min.js');