Skip to content

Commit 702eb67

Browse files
committed
accept object argument to makeHot
1 parent 5d4e865 commit 702eb67

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

lib/make-hot.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,38 @@ const createMakeHot = ({ walk, meta = 'import.meta', hotApi, adapter }) => {
175175
return accessors
176176
}
177177

178-
function makeHot(
179-
id,
180-
compiledCode,
181-
hotOptionsArg,
182-
compiled,
183-
originalCode,
184-
compileOptions
185-
) {
178+
const parseMakeHotArgs = args => {
179+
// case: named args (object)
180+
if (args.length === 1) return args[0]
181+
// case: legacy (positional)
182+
const [
183+
id,
184+
compiledCode,
185+
hotOptionsArg,
186+
compiled,
187+
originalCode,
188+
compileOptions,
189+
] = args
190+
return {
191+
id,
192+
compiledCode,
193+
hotOptionsArg,
194+
compiled,
195+
originalCode,
196+
compileOptions,
197+
}
198+
}
199+
200+
function makeHot(...args) {
201+
const {
202+
id,
203+
compiledCode,
204+
hotOptions: hotOptionsArg,
205+
compiled,
206+
originalCode,
207+
compileOptions,
208+
} = parseMakeHotArgs(args)
209+
186210
const hotOptions = Object.assign({}, defaultHotOptions, hotOptionsArg)
187211

188212
const { importAdapterName } = hotOptions

0 commit comments

Comments
 (0)