How to use the @rollup/pluginutils.makeLegalIdentifier function in @rollup/pluginutils

To help you get started, we’ve selected a few @rollup/pluginutils 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 rollup / plugins / packages / inject / src / index.js View on Github external
function handleReference(node, name, keypath) {
        let mod = modulesMap.get(keypath);
        if (mod && !imports.has(name) && !scope.contains(name)) {
          if (typeof mod === 'string') mod = [mod, 'default'];

          // prevent module from importing itself
          if (mod[0] === id) return false;

          const hash = `${keypath}:${mod[0]}:${mod[1]}`;

          const importLocalName =
            name === keypath ? name : makeLegalIdentifier(`$inject_${keypath}`);

          if (!newImports.has(hash)) {
            if (mod[1] === '*') {
              newImports.set(hash, `import * as ${importLocalName} from '${mod[0]}';`);
            } else {
              newImports.set(hash, `import { ${mod[1]} as ${importLocalName} } from '${mod[0]}';`);
            }
          }

          if (name !== keypath) {
            magicString.overwrite(node.start, node.end, importLocalName, {
              storeName: true
            });
          }

          return true;
github rollup / plugins / packages / commonjs / src / transform.js View on Github external
node.right.properties.forEach((prop) => {
            if (prop.computed || !('key' in prop) || prop.key.type !== 'Identifier') return;
            const { name } = prop.key;
            if (name === makeLegalIdentifier(name)) namedExports[name] = true;
          });
          return;
github rollup / plugins / packages / yaml / src / index.js View on Github external
      const keys = Object.keys(data).filter((key) => key === makeLegalIdentifier(key));
      const code = `var data = ${toSource(data)};\n\n`;

@rollup/pluginutils

A set of utility functions commonly used by Rollup plugins

MIT
Latest version published 6 months ago

Package Health Score

97 / 100
Full package analysis