How to use is-module - 3 common examples

To help you get started, we’ve selected a few is-module examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xyc / vscode-mdx-preview / packages / extension / module-fetcher / transform.ts View on Github external
preview.generateTypescriptConfiguration(null);
    }
    const { tsCompilerOptions } = preview.typescriptConfiguration;
    code = tsTranspileModule(code, {
      compilerOptions: tsCompilerOptions,
      fileName: fsPath,
    }).outputText;
  }

  // Transform:
  // - exclude node_modules
  // - include file in node_modules only if it's es module
  const isInNodeModules = fsPath.split(path.sep).includes('node_modules');
  if (
    !isInNodeModules ||
    isModule(code)
  ) {
    console.log(`Transpiling: ${fsPath}`);
    // use sucrase to transpile node_module files as it's faster
    if (isInNodeModules || useSucrase) {
      try {
        code = (sucraseTransform(code)).code;
      } catch (error) {
        code = (await babelTransformAsync(code)).code;
      }
    } else {
      code = (await babelTransformAsync(code)).code;
    }
  }

  return code;
}
github rollup / plugins / packages / node-resolve / src / index.js View on Github external
return readFileAsync(resolved, 'utf-8').then((code) =>
              isModule(code)
                ? { id: resolved, moduleSideEffects: hasModuleSideEffects(resolved) }
                : null
            );
github rollup / rollup-plugin-node-resolve / src / index.js View on Github external
							.then(code => isModule( code ) ? {id: resolved, moduleSideEffects: hasModuleSideEffects(resolved)} : null);
					} else {

is-module

check if a source string is an es6 module

MIT
Latest version published 11 years ago

Package Health Score

65 / 100
Full package analysis

Popular is-module functions