Skip to content

Commit e7d6fad

Browse files
committed
fix: Deliver both 'visitor' and 'visitors' for Glimmer AST Plugins.
1 parent c447f2f commit e7d6fad

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Diff for: packages/@css-blocks/ember-cli/index.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ GLIMMER_MODULE_CONFIG.collections.components.types.push("stylesheet");
1515
// Default tree hook no-op function.
1616
const NOOP = (tree) => tree;
1717

18+
// Default no-op plugin for templates with no associated CSS Block.
19+
// `visitors` is used by Ember < 3.0.0. `visitor` is used by Glimmer and Ember >= 3.0.0.
20+
const NOOP_PLUGIN = { name: 'css-blocks-noop', visitors: {}, visitor: {} };
21+
1822
module.exports = {
1923
name: '@css-blocks/ember-cli',
2024
isDevelopingAddon() { return true; },
@@ -37,7 +41,7 @@ module.exports = {
3741
// If there is no analyzer or mapping for this template in the transport, don't do anything.
3842
if (!transport) {
3943
DEBUG(`No transport object found found for "${modulePrefix}". Skipping rewrite.`);
40-
return { name: 'css-blocks-noop', visitors: {} };
44+
return NOOP_PLUGIN;
4145
}
4246

4347
// Woo, shared memory wormhole!...
@@ -46,12 +50,12 @@ module.exports = {
4650
// If there is no analyzer or mapping for this template in the transport, don't do anything.
4751
if (!analyzer || !mapping) {
4852
DEBUG(`No mapping object found found for template "${env.meta.moduleName || env.meta.specifier}". Skipping rewrite.`);
49-
return { name: 'css-blocks-noop', visitors: {} };
53+
return NOOP_PLUGIN;
5054
}
5155

5256
// If no specifier data for this template, pass through silently.
5357
if (!env.meta.moduleName && !env.meta.specifier) {
54-
return { name: 'css-blocks-noop', visitors: {} };
58+
return NOOP_PLUGIN;
5559
}
5660

5761
// TODO: Write a better `getAnalysis` method on `Analyzer`
@@ -66,7 +70,7 @@ module.exports = {
6670
// If there is no analysis for this template in any of the transports, don't do anything.
6771
if (!analysis) {
6872
DEBUG(`No analysis found for template "${env.meta.moduleName || env.meta.specifier}". Skipping rewrite.`);
69-
return { name: 'css-blocks-noop', visitors: {} };
73+
return NOOP_PLUGIN;
7074
}
7175

7276
// If we do have a matching analysis, run the rewriter transforms!

Diff for: packages/@css-blocks/glimmer/src/Rewriter.ts

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export class GlimmerRewriter implements ASTPlugin {
5757
}
5858

5959
get name(): string { return this.block ? "css-blocks-glimmer-rewriter" : "css-blocks-noop"; }
60+
61+
// `visitors` is used by Ember < 3.0.0. `visitor` is used by Glimmer and Ember >= 3.0.0.
6062
get visitor(): NodeVisitor { return this.visitors; }
6163
get visitors(): NodeVisitor {
6264
if (!this.block) { return {}; }

0 commit comments

Comments
 (0)