Skip to content

feat(sourceMap): Make source-mapping of multi-files component working… #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ module.exports = function (src, path) {
const script = result.code
const inputMap = result.sourceMap

const map = generateSourceMap(script, '', path, src, inputMap)
let scriptSrc = src
if (parts.script && parts.script.src) {
scriptSrc = parts.script.content
}

const map = generateSourceMap(script, '', path, scriptSrc, inputMap)
let output = ';(function(){\n' + script + '\n})()\n' +
'if (module.exports.__esModule) module.exports = module.exports.default\n' +
'var __vue__options__ = (typeof module.exports === "function"' +
Expand Down
7 changes: 7 additions & 0 deletions test/Babel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,10 @@ test('generates inline sourcemap', () => {
const output = jestVue.process(fileString, filePath)
expect(output.map).toMatchSnapshot()
})

test('generates inline sourcemap for .vue files using src attributes', () => {
const filePath = resolve(__dirname, './resources/BasicSrc.vue')
const fileString = readFileSync(filePath, { encoding: 'utf8' })
const output = jestVue.process(fileString, filePath)
expect(output.map).toMatchSnapshot()
})
37 changes: 37 additions & 0 deletions test/__snapshots__/Babel.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,40 @@ Object {
"version": 3,
}
`;

exports[`generates inline sourcemap for .vue files using src attributes 1`] = `
Object {
"mappings": ";;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAHA;AAKA;AAPA;AASA;AACA;AACA;AACA;AAFA;AAIA;AACA;AACA;AACA;AACA;AAHA;AAjBA",
"names": Array [],
"sources": Array [
"BasicSrc.vue",
],
"sourcesContent": Array [
"export default {
name: 'basic',
computed: {
headingClasses: function headingClasses () {
return {
red: this.isCrazy,
blue: !this.isCrazy,
shadow: this.isCrazy
}
}
},
data: function data () {
return {
msg: 'Welcome to Your Vue.js App',
isCrazy: false
}
},
methods: {
toggleClass: function toggleClass () {
this.isCrazy = !this.isCrazy
}
}
}
",
],
"version": 3,
}
`;