-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix e2e vue-cli
Babel 8 tests
#13050
Changes from 6 commits
ee6d7f1
c59c73d
fc01e8e
013c3d9
8b61580
5acc48b
276d3b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
diff --git a/packages/@vue/babel-preset-app/__tests__/babel-preset.spec.js b/packages/@vue/babel-preset-app/__tests__/babel-preset.spec.js | ||
index d57f42b..724bb37 100644 | ||
--- a/packages/@vue/babel-preset-app/__tests__/babel-preset.spec.js | ||
+++ b/packages/@vue/babel-preset-app/__tests__/babel-preset.spec.js | ||
@@ -3,7 +3,8 @@ const babel = require('@babel/core') | ||
const preset = require('../index') | ||
const defaultOptions = { | ||
babelrc: false, | ||
- presets: [preset], | ||
+ targets: { ie: 9 }, | ||
+ presets: [[preset, { targets: { ie: 9 } }]], | ||
filename: 'test-entry-file.js' | ||
} | ||
|
||
@@ -21,6 +22,7 @@ test('polyfill detection', () => { | ||
const a = new Map() | ||
`.trim(), { | ||
babelrc: false, | ||
+ targets: { ie: 9 }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Why should we patch given that the preset has specified There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh right, it's not necessary. It was my first attempt at fixing these tests, and since it reduced the number of failure I didn't realize it's not what caused them. |
||
presets: [[preset, { | ||
targets: { node: 'current' } | ||
}]], | ||
@@ -35,6 +37,7 @@ test('polyfill detection', () => { | ||
const a = new Map() | ||
`.trim(), { | ||
babelrc: false, | ||
+ targets: { ie: 9 }, | ||
presets: [[preset, { | ||
targets: { ie: 9 } | ||
}]], | ||
@@ -55,6 +58,7 @@ test('modern mode always skips unnecessary polyfills', () => { | ||
console.log(globalThis) | ||
`.trim(), { | ||
babelrc: false, | ||
+ targets: { ie: 9 }, | ||
presets: [[preset, { | ||
targets: { ie: 9, safari: '12' }, | ||
useBuiltIns: 'usage' | ||
@@ -82,6 +86,7 @@ test('modern mode always skips unnecessary polyfills', () => { | ||
const a = new Map() | ||
`.trim(), { | ||
babelrc: false, | ||
+ targets: { ie: 9 }, | ||
presets: [[preset, { | ||
targets: { ie: 9, safari: '12' }, | ||
useBuiltIns: 'entry' | ||
@@ -144,6 +149,7 @@ test('jsx options', () => { | ||
} | ||
`.trim(), { | ||
babelrc: false, | ||
+ targets: { ie: 9 }, | ||
presets: [[preset, { | ||
jsx: { | ||
injectH: false | ||
@@ -160,7 +166,9 @@ test('disable absoluteRuntime', () => { | ||
const a = [...arr] | ||
`.trim(), { | ||
babelrc: false, | ||
+ targets: { ie: 9 }, | ||
presets: [[preset, { | ||
+ targets: { ie: 9 }, | ||
absoluteRuntime: false | ||
}]], | ||
filename: 'test-entry-file.js' | ||
@@ -182,7 +190,9 @@ test('should inject polyfills / helpers using "require" statements for a umd mod | ||
})) | ||
`.trim(), { | ||
babelrc: false, | ||
+ targets: { ie: 9 }, | ||
presets: [[preset, { | ||
+ targets: { ie: 9 }, | ||
absoluteRuntime: false | ||
}]], | ||
filename: 'test-entry-file.js' | ||
@@ -199,7 +209,9 @@ test('should inject polyfills / helpers using "import" statements for an es modu | ||
new Promise() | ||
`.trim(), { | ||
babelrc: false, | ||
+ targets: { ie: 9 }, | ||
presets: [[preset, { | ||
+ targets: { ie: 9 }, | ||
absoluteRuntime: false | ||
}]], | ||
filename: 'test-entry-file.js' | ||
@@ -215,7 +227,9 @@ test('should not inject excluded polyfills', () => { | ||
new Promise() | ||
`.trim(), { | ||
babelrc: false, | ||
+ targets: { ie: 9 }, | ||
presets: [[preset, { | ||
+ targets: { ie: 9 }, | ||
exclude: ['es.promise'], | ||
polyfills: ['es.array.iterator', 'es.object.assign'] | ||
}]], | ||
diff --git a/packages/@vue/cli-plugin-babel/__tests__/transpileDependencies.spec.js b/packages/@vue/cli-plugin-babel/__tests__/transpileDependencies.spec.js | ||
index 1c5d6c2..6f90582 100644 | ||
--- a/packages/@vue/cli-plugin-babel/__tests__/transpileDependencies.spec.js | ||
+++ b/packages/@vue/cli-plugin-babel/__tests__/transpileDependencies.spec.js | ||
@@ -78,6 +78,14 @@ test('dep from node_modules should been transpiled when matched by transpileDepe | ||
'vue.config.js', | ||
`module.exports = { transpileDependencies: ['external-dep', '@scope/external-dep'] }` | ||
) | ||
+ await project.write( | ||
+ 'babel.config.js', | ||
+ `module.exports = { | ||
+ presets: [ | ||
+ ["@vue/babel-preset-app", { targets: { ie: 9 } }] | ||
+ ] | ||
+ }` | ||
+ ) | ||
await project.run('vue-cli-service build') | ||
expect(await readVendorFile()).toMatch('return "__TEST__"') | ||
|
||
@@ -89,6 +97,14 @@ test('dep from node_modules should been transpiled when transpileDependencies is | ||
'vue.config.js', | ||
`module.exports = { transpileDependencies: true }` | ||
) | ||
+ await project.write( | ||
+ 'babel.config.js', | ||
+ `module.exports = { | ||
+ presets: [ | ||
+ ["@vue/babel-preset-app", { targets: { ie: 9 } }] | ||
+ ] | ||
+ }` | ||
+ ) | ||
await project.run('vue-cli-service build') | ||
expect(await readVendorFile()).toMatch('return "__TEST__"') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ended up doing a patch, it feels less hacky than a regexp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, noticed vue-cli had one too!