0

In example, you would have

var browserSync = require('browser-sync').create();

When trying to make this an import, is there a reliable way to append the .create method to the import or would this have to be something like browserSync.create().init({...})?

Another example would be

var debug = require('debug')('http')

which we can rewrite as

var debug = require('debug')
debug('test')('http');

Can this be rewritten with import ?

Hewe
  • 159
  • 1
  • 12
  • @pascalpuetz as far as the second issue, yes. Thank you for pointing me in the right direction. I suppose the first example would follow the same path, in that we need to create an extra variable? – Hewe Sep 23 '20 at 20:18
  • It's the same in both cases. Require returns an object in the first case, a function in the second. You can't use any of these in the same statement as you are importing them. So in both cases, you need to add another line. In your first example this would look something like: `import {create} from 'browser-sync';` and then `const browserSync = create();` – pascalpuetz Sep 23 '20 at 22:00

0 Answers0