How to use the @babel/helper-module-imports.addDefault function in @babel/helper-module-imports

To help you get started, we’ve selected a few @babel/helper-module-imports 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 Jordaneisenburger / fallback-studio / src / pwa-studio / packages / pwa-buildpack / src / magento-layout-loader / babel-plugin-magento-layout.js View on Github external
insertElementAdjacentToChild(position) {
        const { containerPath, currentOperation, onWarning } = this;
        const { targetChild, componentPath } = currentOperation;
        const targetChildPath = this.findContainerChildByName(targetChild);
        if (!targetChildPath) {
            onWarning(
                `Attempted to inject a PWA Studio extension, but specified targetChild was not found\n` +
                    `operation: ${currentOperation.operation}\n` +
                    `targetContainer: ${currentOperation.targetContainer}\n` +
                    `targetChild: ${currentOperation.targetChild}`
            );
            return;
        }
        const componentIdent = addDefault(targetChildPath, componentPath, {
            nameHint: 'Extension'
        }).name;
        // TODO: extensionNode needs to be wrapped in a new ContainerChild,
        // and an error boundary
        const extensionNode = this.buildCreateElementCall(componentIdent);
        this.insertAdjacentArgumentsNode(
            position,
            containerPath,
            targetChildPath.node,
            extensionNode
        );
    }
github ant-design / babel-plugin-import / src / Plugin.js View on Github external
importMethod(methodName, file, pluginState) {
    if (!pluginState.selectedMethods[methodName]) {
      const libraryDirectory = this.libraryDirectory;
      const style = this.style;
      const transformedMethodName = this.camel2UnderlineComponentName  // eslint-disable-line
        ? transCamel(methodName, '_')
        : this.camel2DashComponentName
          ? transCamel(methodName, '-')
          : methodName;
      const path = winPath(
        this.customName ? this.customName(transformedMethodName) : join(this.libraryName, libraryDirectory, transformedMethodName, this.fileName) // eslint-disable-line
      );
      pluginState.selectedMethods[methodName] = this.transformToDefaultImport  // eslint-disable-line
        ? addDefault(file.path, path, { nameHint: methodName })
        : addNamed(file.path, methodName, path);
      if (this.customStyleName) {
        const stylePath = winPath(this.customStyleName(transformedMethodName));
        addSideEffect(file.path, `${stylePath}`);
      } else if (this.styleLibraryDirectory) {
        const stylePath = winPath(
          join(this.libraryName, this.styleLibraryDirectory, transformedMethodName, this.fileName)
        );
        addSideEffect(file.path, `${stylePath}`);
      } else if (style === true) {
        addSideEffect(file.path, `${path}/style`);
      } else if (style === 'css') {
        addSideEffect(file.path, `${path}/style/css`);
      } else if (typeof style === 'function') {
        const stylePath = style(path, file);
        if (stylePath) {
github indico / js-flask-urls / packages / flask-urls.macro / src / flask-urls.macro.js View on Github external
});
      }

      replacement = buildFuncMock({
        FUNC: builderFuncId,
        ENDPOINT: t.stringLiteral(endpoint),
      });
    } else {
      const data = config.urlMap[endpoint];
      if (!data) {
        throw new MacroError('flask-url.macro must reference a valid flask endpoint');
      }

      // generate import
      if (!builderFuncId) {
        builderFuncId = addDefaultImport(state.file.path, config.builder, {
          nameHint: 'buildFlaskURL',
        });
      }

      replacement = buildFunc({
        FUNC: builderFuncId,
        RULE: t.valueToNode(data),
        BASE: t.stringLiteral(config.basePath),
      });
    }

    // replace the tagged template expression with the builder function
    parentPath.replaceWith(replacement);
  });
};
github emotion-js / emotion / packages / babel-plugin-emotion / src / styled-macro.js View on Github external
let getOriginalImportPathStyledIdentifier = () => {
        if (originalImportPathStyledIdentifier === undefined) {
          originalImportPathStyledIdentifier = addDefault(
            state.file.path,
            originalImportPath,
            {
              nameHint: 'styled'
            }
          )
        }
        return t.cloneDeep(originalImportPathStyledIdentifier)
      }
      if (importPath === originalImportPath) {
github salesforce / lwc / packages / @lwc / babel-plugin-component / src / post-process / transform.js View on Github external
function importDefaultTemplate(path, state) {
        const componentName = getBaseName(state);
        return moduleImports.addDefault(path, `./${componentName}.html`, {
            nameHint: 'tmpl',
        });
    }
github bem / bem-react / scripts / rollup / transform-object-assign-require.js View on Github external
function getAssignIdentifier(path, file, state) {
    if (state.id) {
        return state.id;
    }
    state.id = addDefault(path, 'object-assign', { nameHint: 'assign' })
    return state.id;
}
github emotion-js / emotion / packages / babel-plugin-emotion / src / styled-macro.js View on Github external
let getStyledIdentifier = () => {
        if (_styledIdentifier === undefined) {
          _styledIdentifier = addDefault(state.file.path, importPath, {
            nameHint: 'styled'
          })
        }
        return t.cloneDeep(_styledIdentifier)
      }
      let originalImportPathStyledIdentifier
github faceyspacey / babel-plugin-universal-import / index.js View on Github external
function getImport(p, { source, nameHint }) {
  return addDefault(p, source, { nameHint })
}
github facebook / metro / packages / metro-babel7-plugin-react-transform / src / index.js View on Github external
const transformImports = transform.imports.map(importName => {
          return addDefault(path, importName, {hint: importName});
        });

@babel/helper-module-imports

Babel helper functions for inserting module loads

MIT
Latest version published 13 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages