chore: don't include babel compiled files in webpack bundles (#9491)
This commit is contained in:
parent
e5a3c9b907
commit
bb77912aee
|
|
@ -12,7 +12,6 @@
|
||||||
"@babel/plugin-transform-modules-commonjs"
|
"@babel/plugin-transform-modules-commonjs"
|
||||||
],
|
],
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"**/*.d.ts",
|
"**/*.d.ts"
|
||||||
"packages/playwright-core/src/injected/**/*"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -11382,9 +11382,6 @@
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright": "cli.js"
|
"playwright": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
|
||||||
"@zip.js/zip.js": "^2.3.17"
|
|
||||||
},
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
|
|
@ -17948,7 +17945,6 @@
|
||||||
"playwright-core": {
|
"playwright-core": {
|
||||||
"version": "file:packages/playwright-core",
|
"version": "file:packages/playwright-core",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@zip.js/zip.js": "^2.3.17",
|
|
||||||
"commander": "^8.2.0",
|
"commander": "^8.2.0",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"extract-zip": "^2.0.1",
|
"extract-zip": "^2.0.1",
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ export class RecorderApp extends EventEmitter {
|
||||||
await this._page._setServerRequestInterceptor(async route => {
|
await this._page._setServerRequestInterceptor(async route => {
|
||||||
if (route.request().url().startsWith('https://playwright/')) {
|
if (route.request().url().startsWith('https://playwright/')) {
|
||||||
const uri = route.request().url().substring('https://playwright/'.length);
|
const uri = route.request().url().substring('https://playwright/'.length);
|
||||||
const file = require.resolve('../../../web/recorder/' + uri);
|
const file = require.resolve('../../../webpack/recorder/' + uri);
|
||||||
const buffer = await fs.promises.readFile(file);
|
const buffer = await fs.promises.readFile(file);
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ export async function showTraceViewer(traceUrl: string, browserName: string, hea
|
||||||
|
|
||||||
server.routePrefix('/', (request, response) => {
|
server.routePrefix('/', (request, response) => {
|
||||||
const relativePath = new URL('http://localhost' + request.url!).pathname;
|
const relativePath = new URL('http://localhost' + request.url!).pathname;
|
||||||
const absolutePath = path.join(__dirname, '..', '..', '..', 'web', 'traceViewer', ...relativePath.split('/'));
|
const absolutePath = path.join(__dirname, '..', '..', '..', 'webpack', 'traceViewer', ...relativePath.split('/'));
|
||||||
return server.serveFile(response, absolutePath);
|
return server.serveFile(response, absolutePath);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ module.exports = {
|
||||||
output: {
|
output: {
|
||||||
globalObject: 'self',
|
globalObject: 'self',
|
||||||
filename: '[name].bundle.js',
|
filename: '[name].bundle.js',
|
||||||
path: path.resolve(__dirname, '../../../lib/web/htmlReport')
|
path: path.resolve(__dirname, '../../../lib/webpack/htmlReport')
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ module.exports = {
|
||||||
output: {
|
output: {
|
||||||
globalObject: 'self',
|
globalObject: 'self',
|
||||||
filename: '[name].bundle.js',
|
filename: '[name].bundle.js',
|
||||||
path: path.resolve(__dirname, '../../../lib/web/recorder')
|
path: path.resolve(__dirname, '../../../lib/webpack/recorder')
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ module.exports = {
|
||||||
output: {
|
output: {
|
||||||
globalObject: 'self',
|
globalObject: 'self',
|
||||||
filename: '[name].bundle.js',
|
filename: '[name].bundle.js',
|
||||||
path: path.resolve(__dirname, '../../../lib/web/traceViewer')
|
path: path.resolve(__dirname, '../../../lib/webpack/traceViewer')
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ module.exports = {
|
||||||
output: {
|
output: {
|
||||||
globalObject: 'self',
|
globalObject: 'self',
|
||||||
filename: '[name].bundle.js',
|
filename: '[name].bundle.js',
|
||||||
path: path.resolve(__dirname, '../../../lib/web/traceViewer')
|
path: path.resolve(__dirname, '../../../lib/webpack/traceViewer')
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
|
@ -45,7 +45,7 @@ module.exports = {
|
||||||
patterns: [
|
patterns: [
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, '../../../../../node_modules/@zip.js/zip.js/dist/zip-no-worker-inflate.min.js'),
|
from: path.resolve(__dirname, '../../../../../node_modules/@zip.js/zip.js/dist/zip-no-worker-inflate.min.js'),
|
||||||
to: path.resolve(__dirname, '../../../lib/web/traceViewer/zip.min.js')
|
to: 'zip.min.js'
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -151,12 +151,12 @@ class HtmlBuilder {
|
||||||
fs.mkdirSync(this._dataFolder, { recursive: true });
|
fs.mkdirSync(this._dataFolder, { recursive: true });
|
||||||
|
|
||||||
// Copy app.
|
// Copy app.
|
||||||
const appFolder = path.join(require.resolve('playwright-core'), '..', 'lib', 'web', 'htmlReport');
|
const appFolder = path.join(require.resolve('playwright-core'), '..', 'lib', 'webpack', 'htmlReport');
|
||||||
for (const file of fs.readdirSync(appFolder))
|
for (const file of fs.readdirSync(appFolder))
|
||||||
fs.copyFileSync(path.join(appFolder, file), path.join(this._reportFolder, file));
|
fs.copyFileSync(path.join(appFolder, file), path.join(this._reportFolder, file));
|
||||||
|
|
||||||
// Copy trace viewer.
|
// Copy trace viewer.
|
||||||
const traceViewerFolder = path.join(require.resolve('playwright-core'), '..', 'lib', 'web', 'traceViewer');
|
const traceViewerFolder = path.join(require.resolve('playwright-core'), '..', 'lib', 'webpack', 'traceViewer');
|
||||||
const traceViewerTargetFolder = path.join(this._reportFolder, 'trace');
|
const traceViewerTargetFolder = path.join(this._reportFolder, 'trace');
|
||||||
fs.mkdirSync(traceViewerTargetFolder, { recursive: true });
|
fs.mkdirSync(traceViewerTargetFolder, { recursive: true });
|
||||||
// TODO (#9471): remove file filter when the babel build is fixed.
|
// TODO (#9471): remove file filter when the babel build is fixed.
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,13 @@ for (const packageDir of packages) {
|
||||||
continue;
|
continue;
|
||||||
steps.push({
|
steps.push({
|
||||||
command: 'npx',
|
command: 'npx',
|
||||||
args: ['babel', ...(watchMode ? ['-w', '--source-maps'] : []), '--extensions', '.ts', '--out-dir', path.join(packageDir, 'lib'), path.join(packageDir, 'src')],
|
args: [
|
||||||
|
'babel',
|
||||||
|
...(watchMode ? ['-w', '--source-maps'] : []),
|
||||||
|
'--extensions', '.ts',
|
||||||
|
'--out-dir', path.join(packageDir, 'lib'),
|
||||||
|
'--ignore', 'packages/playwright-core/src/server/injected/**/*',
|
||||||
|
path.join(packageDir, 'src')],
|
||||||
shell: true,
|
shell: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue