Skip to content

Commit

Permalink
babel plugin to remove addon template
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Dec 8, 2023
1 parent 178a30b commit a016577
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 37 deletions.
37 changes: 0 additions & 37 deletions patches/ember-notify+6.0.4.patch

This file was deleted.

56 changes: 56 additions & 0 deletions plugins/remove-legacy-layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
export function removeLegacyLayout() {
const shouldContinue = (state) => {
const fName = state.file.opts.filename;
return fName.includes('node_modules') && fName.includes('addon');
};
// const { types: t } = babel;
return {
name: 'ast-transform', // not required
visitor: {
ImportDeclaration(path, state) {
if (!shouldContinue(state)) {
return;
}
if (path.node.source.value === '@ember-decorators/component') {
path.remove();
} else if (path.node.source.value.includes('/templates/')) {
path.remove();
}
},
ObjectProperty(path, state) {
if (!shouldContinue(state)) {
return;
}
if (
path.node.value.name === 'layout' &&
path.node.key.name === 'layout'
) {
path.remove();
}
},
ClassProperty(path, state) {
if (!shouldContinue(state)) {
return;
}
if (
path.node.value &&
path.node.value.name === 'layout' &&
path.node.key &&
path.node.key.name === 'layout'
) {
path.remove();
}
},
Decorator(path, state) {
if (!shouldContinue(state)) {
return;
}
if (path.node.expression && path.node.expression.callee) {
if (path.node.expression.callee.name === 'templateLayout') {
path.remove();
}
}
},
},
};
}
2 changes: 2 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import i18nLoader from './plugins/i18n-loader';
import { generateDefineConfig } from './compat/ember-data-private-build-infra/index.ts';
import refBucketTransform from 'ember-ref-bucket/lib/ref-transform.js';
import { babelHotReloadPlugin } from './plugins/hot-reload';
import { removeLegacyLayout } from './plugins/remove-legacy-layout';
export default defineConfig(({ mode }) => {
const isProd = mode === 'production';
const isDev = mode === 'development';
Expand Down Expand Up @@ -414,6 +415,7 @@ function defaultBabelPlugins(isProd: boolean) {
loose: true,
},
],
removeLegacyLayout,
templateCompilationPlugin(isProd),
];
}
Expand Down

0 comments on commit a016577

Please sign in to comment.