mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-23 15:39:28 -05:00
build: use rollup to pack cypress/vue (#15210)
* build: use rollup to pack cypress/vue * fix: remove unnecessary json plugin
This commit is contained in:
committed by
GitHub
parent
f8959e62c6
commit
aae4872305
@@ -42,7 +42,6 @@
|
||||
"@material-ui/pickers": "3.2.10",
|
||||
"@percy/cypress": "2.3.2",
|
||||
"@rollup/plugin-commonjs": "^17.1.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^11.1.1",
|
||||
"@testing-library/cypress": "7.0.1",
|
||||
"@types/chalk": "2.2.0",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import ts from 'rollup-plugin-typescript2'
|
||||
import resolve from '@rollup/plugin-node-resolve'
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
import json from '@rollup/plugin-json'
|
||||
|
||||
import pkg from './package.json'
|
||||
|
||||
@@ -27,7 +26,7 @@ function createEntry (options) {
|
||||
'react-dom',
|
||||
],
|
||||
plugins: [
|
||||
resolve(), commonjs(), json(),
|
||||
resolve(), commonjs(),
|
||||
],
|
||||
output: {
|
||||
banner,
|
||||
|
||||
+12
-4
@@ -2,14 +2,14 @@
|
||||
"name": "@cypress/vue",
|
||||
"version": "0.0.0-development",
|
||||
"description": "Browser-based Component Testing for Vue.js with Cypress.io ✌️🌲",
|
||||
"main": "dist/index.js",
|
||||
"main": "dist/cypress-vue.cjs.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build": "rimraf dist && yarn rollup -c rollup.config.js",
|
||||
"build-prod": "yarn build",
|
||||
"cy:open": "node ../../scripts/cypress.js open-ct --project ${PWD}",
|
||||
"cy:run": "node ../../scripts/cypress.js run-ct --project ${PWD}",
|
||||
"test": "yarn cy:run",
|
||||
"watch": "tsc -w"
|
||||
"watch": "yarn build --watch --watch.exclude ./dist/**/*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vue/test-utils": "1.0.3",
|
||||
@@ -22,6 +22,8 @@
|
||||
"@cypress/code-coverage": "3.8.1",
|
||||
"@cypress/webpack-dev-server": "0.0.0-development",
|
||||
"@intlify/vue-i18n-loader": "1.0.0",
|
||||
"@rollup/plugin-commonjs": "^17.1.0",
|
||||
"@rollup/plugin-node-resolve": "^11.1.1",
|
||||
"@vue/cli-plugin-babel": "~4.4.0",
|
||||
"@vue/cli-service": "~4.4.0",
|
||||
"axios": "0.19.2",
|
||||
@@ -33,6 +35,9 @@
|
||||
"eslint-plugin-vue": "^6.2.2",
|
||||
"find-webpack": "2.1.0",
|
||||
"mocha": "7.1.1",
|
||||
"rollup": "^2.38.5",
|
||||
"rollup-plugin-istanbul": "2.0.1",
|
||||
"rollup-plugin-typescript2": "^0.29.0",
|
||||
"tailwindcss": "1.1.4",
|
||||
"typescript": "3.9.6",
|
||||
"vue": "2.6.11",
|
||||
@@ -51,7 +56,8 @@
|
||||
"vue": "2.x"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
"dist/**/*",
|
||||
"src/**/*.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -69,6 +75,8 @@
|
||||
"cypress",
|
||||
"vue"
|
||||
],
|
||||
"unpkg": "dist/cypress-vue.browser.js",
|
||||
"module": "dist/cypress-vue.esm-bundler.js",
|
||||
"peerDependenciesMeta": {
|
||||
"@cypress/webpack-dev-server": {
|
||||
"optional": true
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import ts from 'rollup-plugin-typescript2'
|
||||
import resolve from '@rollup/plugin-node-resolve'
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
|
||||
import pkg from './package.json'
|
||||
|
||||
const banner = `
|
||||
/**
|
||||
* ${pkg.name} v${pkg.version}
|
||||
* (c) ${new Date().getFullYear()} Cypress.io
|
||||
* Released under the MIT License
|
||||
*/
|
||||
`
|
||||
|
||||
function createEntry (options) {
|
||||
const {
|
||||
format,
|
||||
input,
|
||||
isBrowser,
|
||||
} = options
|
||||
|
||||
const config = {
|
||||
input,
|
||||
external: [
|
||||
'vue',
|
||||
'@vue/test-utils',
|
||||
'@cypress/webpack-dev-server',
|
||||
],
|
||||
plugins: [
|
||||
resolve({ preferBuiltins: true }), commonjs(),
|
||||
],
|
||||
output: {
|
||||
banner,
|
||||
name: 'CypressVue',
|
||||
file: pkg.unpkg,
|
||||
format,
|
||||
globals: {
|
||||
vue: 'Vue',
|
||||
'@vue/test-utils': 'VueTestUtils',
|
||||
},
|
||||
exports: 'auto',
|
||||
},
|
||||
}
|
||||
|
||||
if (input === 'src/index.ts') {
|
||||
if (format === 'es') {
|
||||
config.output.file = pkg.module
|
||||
if (isBrowser) {
|
||||
config.output.file = pkg.unpkg
|
||||
}
|
||||
}
|
||||
|
||||
if (format === 'cjs') {
|
||||
config.output.file = pkg.main
|
||||
}
|
||||
} else {
|
||||
config.output.file = input.replace(/^src\//, 'dist/')
|
||||
}
|
||||
|
||||
console.log(`Building ${format}: ${config.output.file}`)
|
||||
|
||||
config.plugins.push(
|
||||
ts({
|
||||
check: format === 'es' && isBrowser,
|
||||
tsconfigOverride: {
|
||||
compilerOptions: {
|
||||
declaration: format === 'es',
|
||||
target: 'es5', // not sure what this should be?
|
||||
module: format === 'cjs' ? 'es2015' : 'esnext',
|
||||
},
|
||||
exclude: ['tests'],
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
export default [
|
||||
createEntry({ format: 'es', input: 'src/index.ts', isBrowser: false }),
|
||||
createEntry({ format: 'es', input: 'src/index.ts', isBrowser: true }),
|
||||
createEntry({ format: 'iife', input: 'src/index.ts', isBrowser: true }),
|
||||
createEntry({ format: 'cjs', input: 'src/index.ts', isBrowser: false }),
|
||||
createEntry({ format: 'cjs', input: 'src/support.js', isBrowser: false }),
|
||||
createEntry({ format: 'cjs', input: 'src/plugins/webpack/index.js', isBrowser: false }),
|
||||
]
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
const VueLoaderPlugin = require('vue-loader/lib/plugin')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const path = require('path')
|
||||
const pkg = require('package.json')
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
@@ -18,7 +19,7 @@ module.exports = {
|
||||
extensions: ['.js', '.json', '.vue'],
|
||||
alias: {
|
||||
// point at the built file
|
||||
'@cypress/vue': path.join(__dirname, 'dist'),
|
||||
'@cypress/vue': path.join(__dirname, pkg.main),
|
||||
vue: 'vue/dist/vue.esm.js',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -4799,13 +4799,6 @@
|
||||
magic-string "^0.25.7"
|
||||
resolve "^1.17.0"
|
||||
|
||||
"@rollup/plugin-json@^4.1.0":
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@rollup/plugin-json/-/plugin-json-4.1.0.tgz#54e09867ae6963c593844d8bd7a9c718294496f3"
|
||||
integrity sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==
|
||||
dependencies:
|
||||
"@rollup/pluginutils" "^3.0.8"
|
||||
|
||||
"@rollup/plugin-node-resolve@^11.1.1":
|
||||
version "11.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.1.1.tgz#47bc34252914794a1b06fb50371d7520a03f91f3"
|
||||
@@ -4818,7 +4811,7 @@
|
||||
is-module "^1.0.0"
|
||||
resolve "^1.19.0"
|
||||
|
||||
"@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0":
|
||||
"@rollup/pluginutils@^3.1.0":
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
|
||||
integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
|
||||
|
||||
Reference in New Issue
Block a user