Skip to content

Commit

Permalink
closes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Feb 14, 2020
1 parent 7c874fb commit 1aa1115
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function hotReload(path) {
})()`
}

export default function(source) {
export default function(source, map, meta) {
// parse the user query
const query = getOptions(this) || {}

Expand All @@ -29,23 +29,26 @@ export default function(source) {
return acc
}, {})

// compile and generate sourcemaps
const {code, map} = compile(
source,
{
...opts,
file: this.resourcePath
}
)

// generate the output code
// convert webpack's absolute path to a script-friendly string for hotReload
const escapedPath = stringifyRequest(this, this.resourcePath)
const output = `${code}${opts.hot ? hotReload(escapedPath) : ''}`
try {
// compile and generate sourcemaps
const {code, map} = compile(
source,
{
...opts,
file: this.resourcePath
}
)
// generate the output code
// convert webpack's absolute path to a script-friendly string for hotReload
const escapedPath = stringifyRequest(this, this.resourcePath)
const output = `${code}${opts.hot ? hotReload(escapedPath) : ''}`

// cache this module
if (this.cacheable) this.cacheable()
// cache this module
if (this.cacheable) this.cacheable()

// return code and sourcemap
this.callback(null, output, map)
// return code and sourcemap
this.callback(null, output, map, meta)
} catch(error) {
this.callback(error, '', map, meta)
}
}

0 comments on commit 1aa1115

Please sign in to comment.