Skip to content

Commit acc358f

Browse files
authored
Merge pull request #255 from nogic1008/hotfix/jest-transform
[BREAKING CHANGE] remove inline source-map on process() output
2 parents e9b25b2 + 1788d59 commit acc358f

File tree

4 files changed

+57
-104
lines changed

4 files changed

+57
-104
lines changed
Lines changed: 52 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,99 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`generates source maps for .vue files 1`] = `
4-
"\\"use strict\\";
4+
Object {
5+
"mappings": ";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAHA;AAKA;AAPA;AASA;AACA;AACA;AACA;AAFA;AAIA;AACA;AACA;AACA;AACA;AAHA;AAjBA;;;;AAvBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA",
6+
"names": Array [],
7+
"sources": Array [
8+
"Basic.vue",
9+
],
10+
"sourcesContent": Array [
11+
"<template>
12+
<div class=\\"hello\\">
13+
<h1 :class=\\"headingClasses\\">{{ msg }}</h1>
14+
</div>
15+
</template>
516
6-
Object.defineProperty(exports, \\"__esModule\\", {
7-
value: true
8-
});
9-
exports[\\"default\\"] = void 0;
10-
//
11-
//
12-
//
13-
//
14-
//
15-
//
16-
//
17-
//
18-
//
19-
//
20-
//
21-
//
22-
//
23-
//
24-
//
25-
//
26-
//
27-
//
28-
//
29-
//
30-
//
31-
//
32-
var _default = {
17+
<style module=\\"css\\">
18+
.testA {
19+
background-color: red;
20+
}
21+
</style>
22+
<style module>
23+
.testB {
24+
background-color: blue;
25+
}
26+
</style>
27+
<style>
28+
.testC {
29+
background-color: blue;
30+
}
31+
</style>
32+
33+
<script>
34+
export default {
3335
name: 'basic',
3436
computed: {
3537
headingClasses: function headingClasses() {
3638
return {
3739
red: this.isCrazy,
3840
blue: !this.isCrazy,
3941
shadow: this.isCrazy
40-
};
42+
}
4143
}
4244
},
4345
data: function data() {
4446
return {
4547
msg: 'Welcome to Your Vue.js App',
4648
isCrazy: false
47-
};
49+
}
4850
},
4951
methods: {
5052
toggleClass: function toggleClass() {
51-
this.isCrazy = !this.isCrazy;
53+
this.isCrazy = !this.isCrazy
5254
}
5355
}
54-
};
55-
exports[\\"default\\"] = _default;
56-
;
57-
var __options__ = typeof exports.default === 'function' ? exports.default.options : exports.default
58-
var render = function() {
59-
var _vm = this
60-
var _h = _vm.$createElement
61-
/* istanbul ignore next */
62-
var _c = _vm._self._c || _h
63-
return _c(\\"div\\", { staticClass: \\"hello\\" }, [
64-
_c(\\"h1\\", { class: _vm.headingClasses }, [_vm._v(_vm._s(_vm.msg))])
65-
])
66-
}
67-
var staticRenderFns = []
68-
render._withStripped = true
69-
70-
__options__.render = render
71-
__options__.staticRenderFns = staticRenderFns
72-
;(function() {
73-
var beforeCreate = __options__.beforeCreate
74-
var styleFn = function () { if(!this['css']) {
75-
this['css'] = {};
7656
}
77-
this['css'] = Object.assign(
78-
this['css'], {\\"testA\\":\\"testA\\"});
79-
if(!this['$style']) {
80-
this['$style'] = {};
57+
</script>
58+
",
59+
],
60+
"version": 3,
8161
}
82-
this['$style'] = Object.assign(
83-
this['$style'], {\\"testB\\":\\"testB\\"});
84-
}
85-
__options__.beforeCreate = beforeCreate ? [].concat(beforeCreate, styleFn) : [styleFn]
86-
})()
87-
88-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkJhc2ljLnZ1ZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQ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ICAgcmV0dXJuIHtcbiAgICAgIG1zZzogJ1dlbGNvbWUgdG8gWW91ciBWdWUuanMgQXBwJyxcbiAgICAgIGlzQ3Jhenk6IGZhbHNlXG4gICAgfVxuICB9LFxuICBtZXRob2RzOiB7XG4gICAgdG9nZ2xlQ2xhc3M6IGZ1bmN0aW9uIHRvZ2dsZUNsYXNzKCkge1xuICAgICAgdGhpcy5pc0NyYXp5ID0gIXRoaXMuaXNDcmF6eVxuICAgIH1cbiAgfVxufVxuPC9zY3JpcHQ+XG4iXX0="
8962
`;
9063

9164
exports[`generates source maps using src attributes 1`] = `
92-
"\\"use strict\\";
93-
94-
Object.defineProperty(exports, \\"__esModule\\", {
95-
value: true
96-
});
97-
exports[\\"default\\"] = void 0;
98-
var _default = {
65+
Object {
66+
"mappings": ";;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAHA;AAKA;AAPA;AASA;AACA;AACA;AACA;AAFA;AAIA;AACA;AACA;AACA;AACA;AAHA;AAjBA",
67+
"names": Array [],
68+
"sources": Array [
69+
"SourceMapsSrc.vue",
70+
],
71+
"sourcesContent": Array [
72+
"export default {
9973
name: 'basic',
10074
computed: {
10175
headingClasses: function headingClasses() {
10276
return {
10377
red: this.isCrazy,
10478
blue: !this.isCrazy,
10579
shadow: this.isCrazy
106-
};
80+
}
10781
}
10882
},
10983
data: function data() {
11084
return {
11185
msg: 'Welcome to Your Vue.js App',
11286
isCrazy: false
113-
};
87+
}
11488
},
11589
methods: {
11690
toggleClass: function toggleClass() {
117-
this.isCrazy = !this.isCrazy;
91+
this.isCrazy = !this.isCrazy
11892
}
11993
}
120-
};
121-
exports[\\"default\\"] = _default;
122-
;
123-
var __options__ = typeof exports.default === 'function' ? exports.default.options : exports.default
124-
var render = function() {
125-
var _vm = this
126-
var _h = _vm.$createElement
127-
/* istanbul ignore next */
128-
var _c = _vm._self._c || _h
129-
return _c(\\"div\\", { staticClass: \\"hello\\" }, [
130-
_c(\\"h1\\", { class: _vm.headingClasses }, [_vm._v(_vm._s(_vm.msg))])
131-
])
13294
}
133-
var staticRenderFns = []
134-
render._withStripped = true
135-
136-
__options__.render = render
137-
__options__.staticRenderFns = staticRenderFns
138-
139-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlNvdXJjZU1hcHNTcmMudnVlIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUhBO0FBS0E7QUFQQTtBQVNBO0FBQ0E7QUFDQTtBQUNBO0FBRkE7QUFJQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBSEE7QUFqQkEiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCB7XG4gIG5hbWU6ICdiYXNpYycsXG4gIGNvbXB1dGVkOiB7XG4gICAgaGVhZGluZ0NsYXNzZXM6IGZ1bmN0aW9uIGhlYWRpbmdDbGFzc2VzKCkge1xuICAgICAgcmV0dXJuIHtcbiAgICAgICAgcmVkOiB0aGlzLmlzQ3JhenksXG4gICAgICAgIGJsdWU6ICF0aGlzLmlzQ3JhenksXG4gICAgICAgIHNoYWRvdzogdGhpcy5pc0NyYXp5XG4gICAgICB9XG4gICAgfVxuICB9LFxuICBkYXRhOiBmdW5jdGlvbiBkYXRhKCkge1xuICAgIHJldHVybiB7XG4gICAgICBtc2c6ICdXZWxjb21lIHRvIFlvdXIgVnVlLmpzIEFwcCcsXG4gICAgICBpc0NyYXp5OiBmYWxzZVxuICAgIH1cbiAgfSxcbiAgbWV0aG9kczoge1xuICAgIHRvZ2dsZUNsYXNzOiBmdW5jdGlvbiB0b2dnbGVDbGFzcygpIHtcbiAgICAgIHRoaXMuaXNDcmF6eSA9ICF0aGlzLmlzQ3JhenlcbiAgICB9XG4gIH1cbn1cbiJdfQ=="
95+
",
96+
],
97+
"version": 3,
98+
}
14099
`;

e2e/__projects__/basic/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ test('generates source maps for .vue files', () => {
3838
const filePath = resolve(__dirname, './components/Basic.vue')
3939
const fileString = readFileSync(filePath, { encoding: 'utf8' })
4040

41-
const { code } = jestVue.process(fileString, filePath, {
41+
const { map } = jestVue.process(fileString, filePath, {
4242
moduleFileExtensions: ['js', 'vue']
4343
})
4444

45-
expect(code).toMatchSnapshot()
45+
expect(map).toMatchSnapshot()
4646
})
4747

4848
test('generates source maps using src attributes', () => {
4949
const filePath = resolve(__dirname, './components/SourceMapsSrc.vue')
5050
const fileString = readFileSync(filePath, { encoding: 'utf8' })
5151

52-
const { code } = jestVue.process(fileString, filePath, {
52+
const { map } = jestVue.process(fileString, filePath, {
5353
moduleFileExtensions: ['js', 'vue']
5454
})
5555

56-
expect(code).toMatchSnapshot()
56+
expect(map).toMatchSnapshot()
5757
})
5858

5959
test('processes .vue file using jsx', () => {

lib/process.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const getCustomTransformer = require('./utils').getCustomTransformer
1313
const loadSrc = require('./utils').loadSrc
1414
const babelTransformer = require('babel-jest')
1515
const compilerUtils = require('@vue/component-compiler-utils')
16-
const convertSourceMap = require('convert-source-map')
1716
const generateCode = require('./generate-code')
1817

1918
function resolveTransformer(lang = 'js', vueJestConfig) {
@@ -134,10 +133,6 @@ module.exports = function(src, filename, config) {
134133
templateLine
135134
)
136135

137-
if (map) {
138-
output.code += '\n' + convertSourceMap.fromJSON(map.toString()).toComment()
139-
}
140-
141136
return {
142137
code: output.code,
143138
map

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,14 @@
6262
},
6363
"peerDependencies": {
6464
"@babel/core": "7.x",
65-
"jest": "^25.x",
65+
"jest": "^25.5.0",
6666
"vue": "^2.x",
6767
"vue-template-compiler": "^2.x"
6868
},
6969
"dependencies": {
7070
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
7171
"@vue/component-compiler-utils": "^3.1.0",
7272
"chalk": "^2.1.0",
73-
"convert-source-map": "^1.6.0",
7473
"extract-from-css": "^0.4.4",
7574
"source-map": "0.5.6",
7675
"ts-jest": "25.5.x"

0 commit comments

Comments
 (0)