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

Support browser-sync.mjs configuration file #2075

Open
2 of 10 tasks
ajiho opened this issue Jun 27, 2024 · 0 comments
Open
2 of 10 tasks

Support browser-sync.mjs configuration file #2075

ajiho opened this issue Jun 27, 2024 · 0 comments

Comments

@ajiho
Copy link

ajiho commented Jun 27, 2024

Issue details

There are many tools that already fully support. mjs format configuration files, such as babel eslint stylelint prettier, etc. I hope BrowserSync also supports it so that I can maintain a consistent style of configuration file suffix format in the project

Steps to reproduce/test case

When I try to change 'browser sync. js' to' browser sync. mjs'`

The file content is as follows

import browserSync from "browser-sync";


export default {
    notify: false,
    port: 3001,
    open: true,
    files: [
        "dist/css/*.css",
        "dist/js/*.js",
        "dist/img/*",
        // "dist/*.html",
    ],
    // watchEvents: [
    //     "change"
    // ],
    reloadDelay: 250,
    reloadDebounce: 250,
    ghostMode: false,
    server: {
        baseDir: ['dist'],
        routes: {
            '/node_modules': '../node_modules'
        }
    }
}

运行browser-sync start --config 'conf/browser-sync.mjs' --port 4000会得到一个错误

node:internal/modules/cjs/loader:1200
    throw new ERR_REQUIRE_ESM(filename, true);
    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\Administrator\Desktop\bootstrap-admin\src\config\bs-config.mjs not supported.
Instead change the require of C:\Users\Administrator\Desktop\bootstrap-admin\src\config\bs-config.mjs to a dynamic import() which is available in all Co
mmonJS modules.
    at Object.default_1 [as default] (C:\Users\Administrator\Desktop\bootstrap-admin\node_modules\.pnpm\[email protected]\node_modules\browser-sync\dis
t\cli\command.start.js:26:26)
    at handleCli (C:\Users\Administrator\Desktop\bootstrap-admin\node_modules\.pnpm\[email protected]\node_modules\browser-sync\dist\bin.js:139:25)
    at handleIncoming (C:\Users\Administrator\Desktop\bootstrap-admin\node_modules\.pnpm\[email protected]\node_modules\browser-sync\dist\bin.js:191:5)
    at runFromCli (C:\Users\Administrator\Desktop\bootstrap-admin\node_modules\.pnpm\[email protected]\node_modules\browser-sync\dist\bin.js:62:16)
    at Object.<anonymous> (C:\Users\Administrator\Desktop\bootstrap-admin\node_modules\.pnpm\[email protected]\node_modules\browser-sync\dist\bin.js:28
:5) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.20.2

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ v 3.0.2 ]
  • Node [ v18.20.2 ]
  • Npm [ 10.5.0 ]

Affected platforms

  • linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI

If CLI, please paste the entire command below

$ browser-sync start --config 'conf/browser-sync.js' --port 4000

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant