live-server icon indicating copy to clipboard operation
live-server copied to clipboard

Consider moving to esm and then build for cjs

Open renhiyama opened this issue 2 years ago • 2 comments

Before submitting an issue, please, see https://github.com/tapio/live-server#troubleshooting

Issue description

As stated in title; because https://esm.sh can't build it properly as __dirname isn't implemented in esm so it makes it impossible for it to properly work. If you don't consider moving to esm, atleast consider putting injection.html as a string, save it to a js file as a string and export it, and then import it. Same for other files. This would fix it :)

Software details

  • Command line used for launching live-server:
  • OS:
  • Browser (if browser related):
  • Node.js version:
  • live-server version:

renhiyama avatar Jul 07 '23 14:07 renhiyama

This runs

import liveServer from 'live-server'

var params = {
	port: 8080,
	host: "0.0.0.0",
	root: "./www",
	open: true,
	ignore: './src',
	file: "index.html",
	wait: 1000,
	mount: [['./scripts', './node_modules']], // Mount a directory to a route.
	logLevel: 2, // 0 = errors only, 1 = some, 2 = lots
	middleware: [function(req, res, next) { next(); }] // Takes an array of Connect-compatible middleware that are injected into the server middleware stack
};
liveServer.start(params);

Axellarator avatar Oct 03 '23 16:10 Axellarator

This runs

import liveServer from 'live-server'

var params = {
	port: 8080,
	host: "0.0.0.0",
	root: "./www",
	open: true,
	ignore: './src',
	file: "index.html",
	wait: 1000,
	mount: [['./scripts', './node_modules']], // Mount a directory to a route.
	logLevel: 2, // 0 = errors only, 1 = some, 2 = lots
	middleware: [function(req, res, next) { next(); }] // Takes an array of Connect-compatible middleware that are injected into the server middleware stack
};
liveServer.start(params);

That's because of how nodejs works. I want use it via URL imports sooo ...

renhiyama avatar Oct 04 '23 13:10 renhiyama