mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-07-28 06:39:33 -04:00
Include Acorn / Esprima only into local PaperScript scope, and locally deactivate AMD.
Closes #255.
This commit is contained in:
parent
85d7237c0f
commit
098f3e84cc
2 changed files with 13 additions and 5 deletions
src/core
|
@ -21,8 +21,16 @@
|
|||
paper.PaperScope.prototype.PaperScript = new function() {
|
||||
var Base = paper.Base,
|
||||
PaperScope = paper.PaperScope,
|
||||
// Locally turn of exporst for inlined acorn / esprima.
|
||||
exports = undefined;
|
||||
// Locally turn of exports and define for inlined acorn / esprima.
|
||||
// Just declaring the local vars is enough, as they will be undefined.
|
||||
exports, define,
|
||||
// The scope into which the library is loaded.
|
||||
scope = this;
|
||||
/*#*/ if (options.version == 'dev') {
|
||||
// As the above inclusion loads code into the global scope during dev,
|
||||
// set scope to window, so we can find the library.
|
||||
scope = window;
|
||||
/*#*/ }
|
||||
/*#*/ if (options.parser == 'acorn') {
|
||||
/*#*/ include('../../components/acorn/acorn.min.js', { exports: false });
|
||||
/*#*/ } else if (options.parser == 'esprima') {
|
||||
|
@ -210,9 +218,9 @@ paper.PaperScope.prototype.PaperScript = new function() {
|
|||
}
|
||||
// Now do the parsing magic
|
||||
/*#*/ if (options.parser == 'acorn') {
|
||||
walkAst(acorn.parse(code, { ranges: true }));
|
||||
walkAst(scope.acorn.parse(code, { ranges: true }));
|
||||
/*#*/ } else if (options.parser == 'esprima') {
|
||||
walkAst(esprima.parse(code, { range: true }));
|
||||
walkAst(scope.esprima.parse(code, { range: true }));
|
||||
/*#*/ }
|
||||
return code;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue