Skip to content

Commit 7e010a5

Browse files
committed
chore: update dependencies to the newest version
1 parent c2c7748 commit 7e010a5

File tree

7 files changed

+3215
-2262
lines changed

7 files changed

+3215
-2262
lines changed

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
moduleFileExtensions: ['js', 'json', 'png', 'ts', 'vue'],
33
transform: {
44
'^.+\\.js$': 'babel-jest',
5-
'^.+\\.ts$': '<rootDir>/node_modules/ts-jest/preprocessor.js',
5+
'^.+\\.ts$': 'ts-jest',
66
'.*.(js|vue|png)$': './test/setup/jest-helper.js'
77
},
88
testMatch: ['**/?(*.)(spec|test).ts']

package.json

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,32 @@
3131
},
3232
"homepage": "https://github.com/vuejs/vue-component-compiler#readme",
3333
"devDependencies": {
34-
"@types/clean-css": "^3.4.30",
34+
"@types/clean-css": "^3.4.32",
3535
"@types/jest": "^25.2.3",
36-
"@types/node": "^9.4.7",
37-
"babel-plugin-external-helpers": "^6.22.0",
38-
"babel-preset-env": "^1.6.1",
36+
"@types/node": "^12.12.42",
37+
"@types/puppeteer": "^3.0.0",
38+
"@babel/core": "^7.9.6",
39+
"@babel/plugin-transform-runtime": "^7.9.6",
40+
"@babel/preset-env": "^7.9.6",
3941
"conventional-changelog": "^1.1.24",
40-
"jest": "^22.4.2",
41-
"pug": "^2.0.3",
42-
"puppeteer": "^1.3.0",
43-
"rollup": "^0.58.2",
44-
"rollup-plugin-babel": "^3.0.4",
45-
"rollup-plugin-commonjs": "^9.1.0",
46-
"rollup-plugin-image": "^1.0.2",
47-
"rollup-plugin-node-resolve": "^3.3.0",
48-
"sass": "^1.18.0",
49-
"ts-jest": "^22.4.2",
50-
"typescript": "^3.2.4",
51-
"typescript-eslint-parser": "^15.0.0",
42+
"jest": "^26.0.1",
43+
"pug": "^2.0.4",
44+
"puppeteer": "^3.1.0",
45+
"rollup": "^2.10.8",
46+
"@rollup/plugin-babel": "^5.0.2",
47+
"@rollup/plugin-commonjs": "^12.0.0",
48+
"@rollup/plugin-image": "^2.0.5",
49+
"@rollup/plugin-node-resolve": "^8.0.0",
50+
"sass": "^1.26.5",
51+
"ts-jest": "^26.0.0",
52+
"typescript": "^3.9.3",
5253
"vue": "^2.5.16",
5354
"vue-template-compiler": "^2.5.16"
5455
},
5556
"optionalDependencies": {
5657
"less": "^3.9.0",
57-
"pug": "^2.0.3",
58-
"sass": "^1.18.0",
58+
"pug": "^2.0.4",
59+
"sass": "^1.26.5",
5960
"stylus": "^0.54.5"
6061
},
6162
"peerDependencies": {

test/baseline.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
import {Browser} from "puppeteer";
12
const puppeteer = require('puppeteer')
23
const { readdirSync } = require('fs')
34
const { join, resolve } = require('path')
45
import { build, open } from './setup/utils'
56

6-
let browser = null
7+
let browser: Browser;
78
const fixtures = readdirSync(join(__dirname, 'fixtures'))
8-
.filter(it => it.endsWith('.vue'))
9-
.map(it => it.replace(/\.vue$/i, ''))
9+
.filter((it: string) => it.endsWith('.vue'))
10+
.map((it: string) => it.replace(/\.vue$/i, ''))
1011

1112
beforeAll(async () => {
1213
browser = await puppeteer.launch({
@@ -16,18 +17,18 @@ beforeAll(async () => {
1617
})
1718
afterAll(async () => browser && (await browser.close()))
1819

19-
fixtures.forEach(it =>
20+
fixtures.forEach((it: string) =>
2021
test(it, async () => {
2122
const filename = join(__dirname, 'fixtures', it + '.vue')
2223
const code = await build(filename)
2324
const page = await open(it, browser, code)
2425
expect(await page.$('#test')).toBeTruthy()
2526
expect(
26-
await page.evaluate(() => document.getElementById('test').textContent)
27+
await page.evaluate(() => document.getElementById('test')!.textContent)
2728
).toEqual(expect.stringContaining('Hello'))
2829
expect(
2930
await page.evaluate(
30-
() => window.getComputedStyle(document.getElementById('test')).color
31+
() => window.getComputedStyle(document.getElementById('test')!).color
3132
)
3233
).toEqual('rgb(255, 0, 0)')
3334

test/setup/utils.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
11
import { rollup } from 'rollup'
2-
import babel from 'rollup-plugin-babel'
3-
import commonjs from 'rollup-plugin-commonjs'
4-
import nodeResolve from 'rollup-plugin-node-resolve'
5-
import image from 'rollup-plugin-image'
2+
import babel from '@rollup/plugin-babel'
3+
import nodeResolve from '@rollup/plugin-node-resolve'
4+
const commonjs = require('@rollup/plugin-commonjs');
5+
const image = require('@rollup/plugin-image');
66
import { readFileSync } from 'fs'
77
import { resolve } from 'path'
8+
import { Browser } from "puppeteer";
9+
import { createCompiler, assemble } from '../..'
10+
import { AssembleResults } from "../../src";
811

912
export { compile, build, open, pack }
1013

1114
function vue() {
1215
return {
1316
name: 'vue',
14-
transform(code, id) {
17+
transform(code: string, id: string) {
1518
if (id.endsWith('.vue')) return compile(id, code)
1619
}
1720
}
1821
}
1922

20-
function inline(filename, code) {
23+
function inline(filename: string, code: string | AssembleResults) {
2124
return {
2225
name: 'Inline',
23-
resolveId(id) {
26+
resolveId(id: string) {
2427
if (id === filename) return filename
2528
},
26-
load(id) {
29+
load(id: string) {
2730
if (id === filename) {
2831
return code
2932
}
3033
}
3134
}
3235
}
3336

34-
function load(ext, handle) {
37+
function load(ext: string, handle: (T: string) => string) {
3538
return {
3639
name: 'load' + ext,
37-
load(id) {
38-
if (id.endsWith(ext)) return handle(id.split(':').pop())
40+
load(id: string) {
41+
if (id.endsWith(ext)) return handle(id.split(':').pop()!)
3942
}
4043
}
4144
}
42-
import { createCompiler, assemble } from '../..'
45+
4346
const compiler = createCompiler({
4447
script: {},
4548
style: { trim: true },
@@ -50,7 +53,7 @@ const compiler = createCompiler({
5053
optimizeSSR: process.env.VUE_ENV === 'server'
5154
}
5255
})
53-
function compile(filename, source) {
56+
function compile(filename: string, source: string) {
5457
const result = compiler.compileToDescriptor(filename, source)
5558

5659
result.styles.forEach(style => {
@@ -61,13 +64,13 @@ function compile(filename, source) {
6164
}
6265

6366
const babelit = babel({
64-
presets: [[require.resolve('babel-preset-env'), { modules: false }]],
65-
plugins: ['external-helpers'],
67+
presets: [[require.resolve('@babel/preset-env'), { modules: false }]],
68+
plugins: ["@babel/plugin-transform-runtime"],
6669
babelrc: false,
67-
runtimeHelpers: true
70+
babelHelpers: 'runtime',
6871
})
6972

70-
async function pack(filename, source) {
73+
async function pack(filename: string, source: string) {
7174
const name = filename + '__temp.js'
7275
let bundle = await rollup(<any>{
7376
input: name,
@@ -78,23 +81,23 @@ async function pack(filename, source) {
7881
plugins: [
7982
load(
8083
'.png',
81-
id =>
84+
(id) =>
8285
`export default "data:image/png;base64,${readFileSync(
8386
id,
8487
'base64'
8588
)}"\n`
8689
),
87-
inline(name, (await bundle.generate({ format: 'cjs' })).code),
90+
inline(name, (await bundle.generate({ format: 'cjs' })).output[0].code),
8891
commonjs(),
8992
babelit
9093
]
9194
})
9295

93-
return (await bundle.generate({ format: 'cjs' })).code
96+
return (await bundle.generate({ format: 'cjs' })).output[0].code
9497
}
9598

96-
const cache = {}
97-
async function build(filename) {
99+
const cache: Record<string, string> = {}
100+
async function build(filename: string) {
98101
if (filename in cache) return cache[filename]
99102
const source = compile(filename, readFileSync(filename).toString())
100103
const component = filename + '__.js'
@@ -134,15 +137,15 @@ async function build(filename) {
134137
vue(),
135138
image(),
136139
commonjs(),
137-
inline(component, generated.code),
140+
inline(component, generated.output[0].code),
138141
babelit
139142
]
140143
})
141144

142145
cache[filename] = (await bundle.generate({
143146
format: 'iife',
144147
name: 'App'
145-
})).code
148+
})).output[0].code
146149

147150
return cache[filename]
148151
}
@@ -151,7 +154,7 @@ const vueSource = readFileSync(
151154
resolve(__dirname, '../../node_modules/vue/dist/vue.min.js')
152155
).toString()
153156
const escape = (any: string) => any.replace(/<\//g, '&lt;\/')
154-
async function open(name, browser, code, id = '#test') {
157+
async function open(name: string, browser: Browser, code: string, id = '#test') {
155158
const page = await browser.newPage()
156159

157160
const content = `

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"strictNullChecks": true,
1414
"noImplicitAny": true,
1515
"removeComments": false,
16-
"lib": ["es6", "es7"],
16+
"lib": ["es6", "es7", "dom"],
1717
"types": ["@types/jest", "node"]
1818
},
1919
"include": ["src", "typings"]

typings/rollup-plugin-babel.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '@rollup/plugin-babel';

0 commit comments

Comments
 (0)