How to use the @babel/traverse.visitors.merge function in @babel/traverse

To help you get started, we’ve selected a few @babel/traverse 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 4Catalyzer / astroturf / src / plugin.js View on Github external
});

      styles = Array.from(styles.values());

      changeset = changeset.concat(styles);

      file.metadata.astroturf = { styles, changeset };

      if (opts.writeFiles !== false) {
        styles.forEach(({ absoluteFilePath, value }) => {
          outputFileSync(absoluteFilePath, stripIndent([value]));
        });
      }
    },

    visitor: visitors.merge([
      {
        Program: {
          enter(_, state) {
            state.defaultedOptions = defaults(state.opts, {
              tagName: 'css',
              allowGlobal: true,
              styledTag: 'styled',
              customCssProperties: 'cssProp', // or: true, false
            });
          },
        },

        ImportDeclaration: {
          exit(path, state) {
            const { tagName } = state.defaultedOptions;
            const specifiers = path.get('specifiers');

@babel/traverse

The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes

MIT
Latest version published 20 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages