nyaggah / bedframe

Your Browser Extension Development Framework
https://bedframe.dev
MIT License
510 stars 5 forks source link

Command failed & emitted file has the same name #567

Open th3-sh0w3r opened 1 week ago

th3-sh0w3r commented 1 week ago

Hello!

I'm using bedframe now for quite some time and it works really well, sometimes the HMR is a bit weird but execpt of this everything is fine.

The only thing which is a bit anoying is that I always get this error when I run the dev server with: bun run dev or bun run dev opera

an error occurred while running commands: 1 | export const getStreamContents = async (stream, {init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize}, {maxBuffer = Number.POSITIVE_INFINITY} = {}) => {
2 |     if (!isAsyncIterable(stream)) {
3 |             throw new Error('The first argument must be a Readable, a ReadableStream, or an async iterable.');
                       ^
error: Command failed: vite --mode opera
The first argument must be a Readable, a ReadableStream, or an async iterable.
      at /usr/src/app/node_modules/get-stream/source/contents.js:3:20
      at getStreamContents (/usr/src/app/node_modules/get-stream/source/contents.js:1:41)
      at getStreamAsString (/usr/src/app/node_modules/get-stream/source/string.js:4:41)
      at /usr/src/app/node_modules/execa/lib/stream.js:119:24
      at getSpawnedResult (/usr/src/app/node_modules/execa/lib/stream.js:118:33)
      at /usr/src/app/node_modules/execa/index.js:118:94
      at /usr/src/app/node_modules/execa/index.js:117:24
      at onetime (/usr/src/app/node_modules/onetime/index.js:18:28)
      at /usr/src/app/node_modules/execa/lib/promise.js:14:51
      at /usr/src/app/node_modules/@bedframe/cli/dist/bedframe.js:139:10

Also those two lines are shown after the vite server is started:

The emitted file "pages/main.html" overwrites a previously emitted file of the same name.
The emitted file "pages/options.html" overwrites a previously emitted file of the same name.

This is my vite config

import { URL, fileURLToPath } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { FontFamily, getFonts, getManifest } from '@bedframe/core';
import bedframe from './src/_config/bedframe.config';
import path from 'node:path';

const { manifest, pages } = bedframe.extension;
const {
    style: { fonts },
    tests
} = bedframe.development.template.config;

export default defineConfig(({ command, mode }) => {
    return {
        css: {
            preprocessorOptions: {
                scss: {
                    api: 'modern-compiler'
                }
            }
        },
        root: 'src',
        publicDir: '../public',
        resolve: {
            alias: {
                '@': fileURLToPath(new URL('./src', import.meta.url)),
                vue$: 'vue/dist/vue.esm-bundler.js',
                vue: path.resolve(`./node_modules/vue`)
            }
        },
        plugins: [
            vue(),
            getManifest({ command, mode }, manifest, {
                browser: mode
            }),
            getFonts(fonts as FontFamily[])
        ],
        build: {
            target: 'esnext',
            outDir: `${__dirname}/dist/${mode}`,
            emptyOutDir: true,
            rollupOptions: {
                input: pages
            }
        },
        test: tests,
        server: {
            port: 4173,
            host: '0.0.0.0',
            hmr: {
                clientPort: 4173
            },
            watch: {
                usePolling: true
            }
        }
    };
});

And my bedframe manifest:

import { type Manifest } from '@bedframe/core';
import pkg from '../../package.json';

export const baseManifest = {
    name: pkg.name,
    version: pkg.version,
    homepage_url: pkg.author.url,
    manifest_version: 3,
    description: pkg.description,
    icons: {
        16: 'assets/icons/logo-16x16.png',
        32: 'assets/icons/logo-32x32.png',
        48: 'assets/icons/logo-48x48.png',
        128: 'assets/icons/logo-128x128.png'
    },
    action: {
        default_icon: {
            16: 'assets/icons/logo-16x16.png',
            32: 'assets/icons/logo-32x32.png',
            48: 'assets/icons/logo-48x48.png',
            128: 'assets/icons/logo-128x128.png'
        },
        default_title: pkg.name,
        default_popup: 'pages/main.html'
    },
    author: pkg.author.email,
    background: {
        service_worker: 'scripts/service-worker.ts',
        type: 'module'
    },
    content_scripts: [
        {
            matches: ['<all_urls>'],
            js: ['scripts/content-script.ts']
        }
    ],
    options_ui: {
        page: 'pages/options.html',
        open_in_tab: false
    },
    web_accessible_resources: [
        {
            resources: ['assets/*', 'pages/*'],
            matches: ['<all_urls>']
        }
    ],
    commands: {
        _execute_action: {
            suggested_key: {
                default: 'Ctrl+Shift+1',
                mac: 'Ctrl+Shift+1',
                linux: 'Ctrl+Shift+1',
                windows: 'Ctrl+Shift+1',
                chromeos: 'Ctrl+Shift+1'
            }
        }
    },
    host_permissions: ['http://*/*', 'https://*/*'],
    permissions: ['activeTab', 'storage', 'scripting', 'background', 'webRequest', 'tabs', 'declarativeNetRequest']
} satisfies Manifest;
JoeyDoey commented 1 day ago

Hey @th3-sh0w3r thanks for checking out Bedframe!

I'm not able to repro your first issue. But for the second thing, see this issue in the Vite's Github issues: https://github.com/vitejs/vite/issues/14316#issuecomment-1723583644

For now, while not ideal, if its just an annoyance, you might be able to just silence the warning

rollupOptions: {
  input: pages,
  // silence the file name conflict warnings
  onwarn: (warning, defaultHandler) => {
    if (warning.code !== 'FILE_NAME_CONFLICT') {
      defaultHandler(warning)
    }
  },
},