mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-09 00:30:16 -06:00
* wip react to rollup * remove comment * chore: update build script * we were tree shaking the support file hooks * updating the scripts for reacts package.json * Revert "updating the scripts for reacts package.json" This reverts commit7ca3ac8e61. * adding watch task without modifying circleci * bundle types correctly * bundle types correctly 2 * fixing support to immediately invoke the new method on hooks * run the hooks only in support * Revert "run the hooks only in support" This reverts commit939e4c5942. * fix: remove hooks from support entirely Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com> Co-authored-by: ElevateBart <ledouxb@gmail.com> Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
80 lines
1.7 KiB
JavaScript
80 lines
1.7 KiB
JavaScript
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'
|
|
|
|
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: [
|
|
'react',
|
|
'react-dom',
|
|
],
|
|
plugins: [
|
|
resolve(), commonjs(), json(),
|
|
],
|
|
output: {
|
|
banner,
|
|
name: 'CypressReact',
|
|
file: pkg.unpkg,
|
|
format,
|
|
globals: {
|
|
react: 'React',
|
|
'react-dom': 'ReactDOM',
|
|
},
|
|
},
|
|
}
|
|
|
|
if (format === 'es') {
|
|
config.output.file = pkg.module
|
|
if (isBrowser) {
|
|
config.output.file = pkg.unpkg
|
|
}
|
|
}
|
|
|
|
if (format === 'cjs') {
|
|
config.output.file = pkg.main
|
|
}
|
|
|
|
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 }),
|
|
]
|