MCPcopy Create free account
hub / github.com/developit/htm / pragmaImport

Function pragmaImport

packages/babel-plugin-htm/index.mjs:22–43  ·  view source on GitHub ↗
(imp)

Source from the content-addressed store, hash-verified

20 const importDeclaration = pragmaImport(options.import || false);
21
22 function pragmaImport(imp) {
23 if (pragmaString === false || imp === false) {
24 return null;
25 }
26 const pragmaRoot = t.identifier(pragmaString.split('.')[0]);
27 const { module, export: export_ } = typeof imp !== 'string' ? imp : {
28 module: imp,
29 export: null
30 };
31
32 let specifier;
33 if (export_ === '*') {
34 specifier = t.importNamespaceSpecifier(pragmaRoot);
35 }
36 else if (export_ === 'default') {
37 specifier = t.importDefaultSpecifier(pragmaRoot);
38 }
39 else {
40 specifier = t.importSpecifier(pragmaRoot, export_ ? t.identifier(export_) : pragmaRoot);
41 }
42 return t.importDeclaration([specifier], t.stringLiteral(module));
43 }
44
45 function dottedIdentifier(keypath) {
46 const path = keypath.split('.');

Callers 1

htmBabelPluginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…