interscript / interscript-js

Interscript in pure JS
Other
2 stars 1 forks source link

return statement outside of a function #15

Closed strogonoff closed 4 years ago

strogonoff commented 4 years ago

Getting the following when a React-static site that has interscript as dependency is generated:

[warning 0]: /Volumes/Ribose-2/interscript/interscript.com/node_modules/interscript/maps/index.js
Module build failed (from /Volumes/Ribose-2/interscript/interscript.com/node_modules/babel-loader/lib/index.js):
SyntaxError: /Volumes/Ribose-2/interscript/interscript.com/node_modules/interscript/maps/index.js: 'return' outside of function (17:4)

  15 |         }, {}))();
  16 | } catch(e) {
> 17 |     return false;
     |     ^
  18 | }
  19 |  void function register() { /* react-hot-loader/webpack */ var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined; if (!reactHotLoader) { return; } /* eslint-disable camelcase, no-undef */ var webpackExports = typeof __webpack_exports__ !== 'undefined' ? __webpack_exports__ : exports; /* eslint-enable camelcase, no-undef */ if (!webpackExports) { return; } if (typeof webpackExports === 'function') { reactHotLoader.register(webpackExports, 'module.exports', "/Volumes/Ribose-2/interscript/interscript.com/node_modules/interscript/maps/index.js"); return; } /* eslint-disable no-restricted-syntax */ for (var key in webpackExports) { /* eslint-enable no-restricted-syntax */ if (!Object.prototype.hasOwnProperty.call(webpackExports, key)) { continue; } var namedExport = void 0; try { namedExport = webpackExports[key]; } catch (err) { continue; } reactHotLoader.register(namedExport, key, "/Volumes/Ribose-2/interscript/interscript.com/node_modules/interscript/maps/index.js"); } }(); 
    at Parser._raise (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/error.js:60:45)
    at Parser.raiseWithData (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/error.js:55:17)
    at Parser.raise (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/error.js:39:17)
    at Parser.parseReturnStatement (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:560:12)
    at Parser.parseStatementContent (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:195:21)
    at Parser.parseStatement (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:149:17)
    at Parser.parseBlockOrModuleBlockBody (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:868:25)
    at Parser.parseBlockBody (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:840:10)
    at Parser.parseBlock (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:810:10)
    at callback (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:672:16)
    at Parser.withTopicForbiddingContext (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/expression.js:2494:14)
    at Parser.parseTryStatement (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:670:14)
    at Parser.parseStatementContent (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:201:21)
    at Parser.parseStatement (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:149:17)
    at Parser.parseBlockOrModuleBlockBody (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:868:25)
    at Parser.parseBlockBody (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:840:10)
    at Parser.parseTopLevel (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/statement.js:55:10)
    at Parser.parse (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/parser/index.js:57:10)
    at parse (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/parser/src/index.js:26:26)
    at parser (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/core/lib/parser/index.js:54:34)
    at parser.next (<anonymous>)
    at normalizeFile (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/core/lib/transformation/normalize-file.js:99:38)
    at normalizeFile.next (<anonymous>)
    at run (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/core/lib/transformation/index.js:31:50)
    at run.next (<anonymous>)
    at Function.transform (/Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/core/lib/transform.js:27:41)
    at transform.next (<anonymous>)
    at step (/Volumes/Ribose-2/interscript/interscript.com/node_modules/gensync/index.js:254:32)
    at /Volumes/Ribose-2/interscript/interscript.com/node_modules/gensync/index.js:266:13
    at async.call.result.err.err (/Volumes/Ribose-2/interscript/interscript.com/node_modules/gensync/index.js:216:11)
    at /Volumes/Ribose-2/interscript/interscript.com/node_modules/gensync/index.js:184:28
    at /Volumes/Ribose-2/interscript/interscript.com/node_modules/@babel/core/lib/gensync-utils/async.js:72:7
    at /Volumes/Ribose-2/interscript/interscript.com/node_modules/gensync/index.js:108:33
    at step (/Volumes/Ribose-2/interscript/interscript.com/node_modules/gensync/index.js:280:14)
    at /Volumes/Ribose-2/interscript/interscript.com/node_modules/gensync/index.js:266:13
    at async.call.result.err.err (/Volumes/Ribose-2/interscript/interscript.com/node_modules/gensync/index.js:216:11)
webdev778 commented 4 years ago

fixed, it dosen't looks like the best practice though. this file was intended for require map file for nodejs environment. require("interscript/maps")[system] Without try catch, It's not working with react cuz "fs" is one of core modules of nodejs. I was trying to figure it out to determine the enviroment with no luck. The solution will eliminate try catch statement. It's a temporary. Let me improve it in the future. @strongonoff welcome to your suggestion