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

babel plugin to remove addon template #72

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading