diff --git a/packages/addon-dev/src/rollup-clean-plugin.ts b/packages/addon-dev/src/rollup-clean-plugin.ts index 8dce56ae4..6ae8b8a37 100644 --- a/packages/addon-dev/src/rollup-clean-plugin.ts +++ b/packages/addon-dev/src/rollup-clean-plugin.ts @@ -1,19 +1,21 @@ -import globSync from 'fast-glob'; -import { rmSync } from 'node:fs'; -import { join } from 'node:path'; +import walkSync from 'walk-sync'; +import { rmSync } from 'fs'; +import { join } from 'path'; +import type { Plugin } from 'rollup'; -export default function clean() { +export default function clean(): Plugin { return { name: 'clean', writeBundle(options, bundle) { - const files = globSync.sync('*/**', { - cwd: options.dir, + const files = walkSync(options.dir!, { + globs: ['*/**'], + directories: false, }); for (const file of files) { if (!bundle[file]) { - rmSync(join(options.dir, file)); + rmSync(join(options.dir!, file)); } } - } - } + }, + }; } diff --git a/packages/addon-dev/src/rollup.ts b/packages/addon-dev/src/rollup.ts index f4056128f..fce966397 100644 --- a/packages/addon-dev/src/rollup.ts +++ b/packages/addon-dev/src/rollup.ts @@ -2,11 +2,10 @@ import { default as hbs } from './rollup-hbs-plugin'; import { default as gjs } from './rollup-gjs-plugin'; import { default as publicEntrypoints } from './rollup-public-entrypoints'; import { default as appReexports } from './rollup-app-reexports'; -import type { Options as DelOptions } from 'rollup-plugin-delete'; -import { default as clean } from 'rollup-plugin-delete'; import { default as keepAssets } from './rollup-keep-assets'; import { default as dependencies } from './rollup-addon-dependencies'; import { default as publicAssets } from './rollup-public-assets'; +import { default as clean } from './rollup-clean-plugin'; import type { Plugin } from 'rollup'; export class Addon { @@ -62,9 +61,9 @@ export class Addon { } // By default rollup does not clear the output directory between builds. This - // does that. - clean(options: DelOptions) { - return clean({ targets: `${this.#destDir}/*`, ...options }); + // does that. It only deletes files that are not part of the generated bundle + clean() { + return clean(); } // V2 Addons are allowed to contain imports of .css files. This tells rollup