Repository navigation
Support browser-sync.mjs configuration file #2075
Copy link
Copy link
Open
Description
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\browser-sync@3.0.2\node_modules\browser-sync\dis
t\cli\command.start.js:26:26)
at handleCli (C:\Users\Administrator\Desktop\bootstrap-admin\node_modules\.pnpm\browser-sync@3.0.2\node_modules\browser-sync\dist\bin.js:139:25)
at handleIncoming (C:\Users\Administrator\Desktop\bootstrap-admin\node_modules\.pnpm\browser-sync@3.0.2\node_modules\browser-sync\dist\bin.js:191:5)
at runFromCli (C:\Users\Administrator\Desktop\bootstrap-admin\node_modules\.pnpm\browser-sync@3.0.2\node_modules\browser-sync\dist\bin.js:62:16)
at Object.<anonymous> (C:\Users\Administrator\Desktop\bootstrap-admin\node_modules\.pnpm\browser-sync@3.0.2\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
Reacted by Rob Huijben, Саша “Nelie” Черных, Rasso Hilber and kaji
Metadata
Metadata
Assignees
Labels
No labels
Activity