Files
cypress/packages/runner/webpack.config.ts
Bill Glesias f3b67666a5 fix: update cypress to Typescript 5 (#29568)
* fix: update the monorepo to typescript 5

* chore: updating v8 snapshot cache

* chore: updating v8 snapshot cache

* chore: updating v8 snapshot cache

* run ci to see problems [run ci]

* update vue-tsc and typings that conflict with update

* regen snapshot

* fix typescript errors ui test as stack trace behavior has changed

* fix server unit tests

* update cy.origin() spec based on stack traces and code frames

* update spec to include source map url

* run ci

* fix check-ts

* chore: fix system tests [run ci]

* add preprocessor tests to batteries included to exercise new logic

* run ci

* refactor unit tests to be a bit more dry

* pin typescript to ~5.4 and adjust config to ignroe deprecations but keep importsNotUsedAsValues

* add changelog entry

* add fixme issue to stack trace mismatches inside evaled context

* use import type webpack as webpack as a lib isn't actually invboked in the runner webpack config

* fix system test as adding 4 lines of comments impacts the stack trace line 4 lines (duh)

---------

Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com>
2024-06-04 19:17:38 -04:00

109 lines
2.6 KiB
TypeScript

import _ from 'lodash'
import { waitUntilIconsBuilt } from '../../scripts/ensure-icons'
import { getCommonConfig, getSimpleConfig, getCopyWebpackPlugin } from '@packages/web-config/webpack.config.base'
import path from 'path'
import type webpack from 'webpack'
const commonConfig = getCommonConfig()
const CopyWebpackPlugin = getCopyWebpackPlugin()
// @ts-ignore
const babelLoader = _.find(commonConfig.module.rules, (rule) => {
// @ts-ignore
return _.includes(rule.use.loader, 'babel-loader')
})
// @ts-ignore
babelLoader.use.options.plugins.push([require.resolve('babel-plugin-prismjs'), {
'languages': ['javascript', 'coffeescript', 'typescript', 'jsx', 'tsx'],
'plugins': ['line-numbers', 'line-highlight'],
'theme': 'default',
'css': false,
}])
// @ts-ignore
const mainConfig: webpack.Configuration = {
...commonConfig,
entry: {
cypress_runner: [path.resolve(__dirname, 'src/index.js')],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
}
mainConfig.resolve = {
...mainConfig.resolve,
alias: {
'bluebird': require.resolve('bluebird'),
'lodash': require.resolve('lodash'),
'mobx': require.resolve('mobx'),
'mobx-react': require.resolve('mobx-react'),
'react': require.resolve('react'),
'react-dom': require.resolve('react-dom'),
},
}
// @ts-ignore
const crossOriginConfig: webpack.Configuration = {
...commonConfig,
entry: {
cypress_cross_origin_runner: [path.resolve(__dirname, 'src/cross-origin.js')],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
}
// @ts-ignore
const mainInjectionConfig: webpack.Configuration = {
...getSimpleConfig(),
mode: 'production',
entry: {
injection: [path.resolve(__dirname, 'injection/main.js')],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
}
// @ts-ignore
const crossOriginInjectionConfig: webpack.Configuration = {
...getSimpleConfig(),
mode: 'production',
entry: {
injection_cross_origin: [path.resolve(__dirname, 'injection/cross-origin.js')],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
}
export default async function () {
await waitUntilIconsBuilt()
const cyIcons = require('@packages/icons')
mainConfig.plugins = [
// @ts-ignore
...mainConfig.plugins,
new CopyWebpackPlugin({
patterns: [{
// @ts-ignore // There's a race condition in how these types are generated.
from: cyIcons.getPathToFavicon('favicon.ico'),
}],
}),
]
return [
mainConfig,
mainInjectionConfig,
crossOriginConfig,
crossOriginInjectionConfig,
]
}