UNPKG

orionsoft-react-scripts

Version:

Orionsoft Configuration and scripts for Create React App.

30 lines (26 loc) 945 B
'use strict' exports.__esModule = true /** * detect possible imports/exports without a full parse. * used primarily to ignore the import/ignore setting, iif it looks like * there might be something there (i.e., jsnext:main is set). * * A negative test means that a file is definitely _not_ a module. * A positive test means it _could_ be. * * Not perfect, just a fast way to disqualify large non-ES6 modules and * avoid a parse. * @type {RegExp} */ exports.potentialModulePattern = new RegExp(`(?:^|;)\s*(?:export|import)(?:(?:\s+\w)|(?:\s*[{*]))`) // future-/Babel-proof at the expense of being a little loose const unambiguousNodeType = /^(Exp|Imp)ort.*Declaration$/ /** * Given an AST, return true if the AST unambiguously represents a module. * @param {Program node} ast * @return {Boolean} */ exports.isModule = function isUnambiguousModule(ast) { return ast.body.some(node => unambiguousNodeType.test(node.type)) }