Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix caching warnings when running under Embroider #742

Merged

Conversation

rwjblue
Copy link
Contributor

@rwjblue rwjblue commented Jun 16, 2021

Prior to this change, you would receive the following warnings during an Embroider build:

broccoli-babel-transpiler is opting out of caching due to a plugin that does not provide a caching strategy: `function(env) {
  let b = env.syntax.builders;
  let transform = (node) => {
    if ('sexpr' in node) {
      node = node.sexpr;
    }

    let testSelectorParams = [];
    let otherParams = [];

    node.params.forEach(function(param) {
      if (isTestSelectorParam(param)) {
        testSelectorParams.push(param);
      } else {
        otherParams.push(param);
      }
    });

    node.params = otherParams;

    testSelectorParams.forEach(function(param) {
      let pair = b.pair(param.original, b.boolean(true));
      node.hash.pairs.push(pair);
    });
  };

  return {
    name: 'TransformTestSelectorParamsToHashPairs',

    visitor: {
      MustacheStatement: transform,
      BlockStatement: transform,
    },
  };
}`

The reason for this warning is that Embroider is attempting to read the caching information (baseDir and cacheKey) from the plugin itself (not the wrapper we register). Some recent changes in Embroider have improved things a bit (reducing the number of cases where this warning will occur), but fixing all scenarios is quite difficult.


This PR works around the issue by placing the caching information on both the registries wrapper object and the plugin itself (ensuring that there is still a single source of truth).

This fixes the warning you get when running in Embroider builds.

Prior to this change, you would receive the following warnings during an Embroider build:

```
broccoli-babel-transpiler is opting out of caching due to a plugin that does not provide a caching strategy: `function(env) {
  let b = env.syntax.builders;
  let transform = (node) => {
    if ('sexpr' in node) {
      node = node.sexpr;
    }

    let testSelectorParams = [];
    let otherParams = [];

    node.params.forEach(function(param) {
      if (isTestSelectorParam(param)) {
        testSelectorParams.push(param);
      } else {
        otherParams.push(param);
      }
    });

    node.params = otherParams;

    testSelectorParams.forEach(function(param) {
      let pair = b.pair(param.original, b.boolean(true));
      node.hash.pairs.push(pair);
    });
  };

  return {
    name: 'TransformTestSelectorParamsToHashPairs',

    visitor: {
      MustacheStatement: transform,
      BlockStatement: transform,
    },
  };
}`
```

The reason for this warning is that Embroider is attempting to read the caching
information (baseDir and cacheKey) from the plugin itself (not the wrapper we
register). Some recent changes in Embroider have improved things a bit
(reducing the number of cases where this warning will occur), but fixing
all scenarios is quite difficult.

---

This PR works around the issue by placing the caching information on
both the registries wrapper object **and** the plugin itself (ensuring
that there is still a single source of truth).

This fixes the warning you get when running in Embroider builds.
Copy link
Collaborator

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds reasonable, thank you! :)

@Turbo87 Turbo87 merged commit a9eb4b1 into mainmatter:master Jun 24, 2021
@rwjblue rwjblue deleted the avoid-caching-warnings-under-embroider branch June 24, 2021 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants