Skip to content

[BUG] Still having issues getting macros to "fully" resolve #98

@matthew-dean

Description

@matthew-dean

Describe the bug
I finally came back to this. I'm still having an issue where not all the function calls will reduce / resolve no matter how much I try to pepper with macros.

Code to reproduce

import { build as $build } from 'xregexp';

// ... tokens and stuff

function $buildFragments(rawFragments: string[][]) {
  const fragments: Record<string, RegExp> = {};
  for (const fragment of rawFragments) {
    fragments[fragment[0]!] = $build!(fragment[1]!, fragments);
  };
  return fragments;
};

export const cssFragments = $buildFragments!(rawCssFragments);

Results in:

export const cssFragments = (() => {
    const fragments = {};
    for (const fragment of rawCssFragments) {
        fragments[fragment[0]] = $build(fragment[1], fragments);
    }
    ;
    return fragments;
})();

Expected behavior
I expected for everything to "resolve" to a single object in the compiled JS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions