chore: don't include babel compiled files in webpack bundles (#9491)

This commit is contained in:
Pavel Feldman 2021-10-13 18:27:50 -08:00 committed by GitHub
parent e5a3c9b907
commit bb77912aee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 17 additions and 16 deletions

View File

@ -12,7 +12,6 @@
"@babel/plugin-transform-modules-commonjs"
],
"ignore": [
"**/*.d.ts",
"packages/playwright-core/src/injected/**/*"
"**/*.d.ts"
]
}

4
package-lock.json generated
View File

@ -11382,9 +11382,6 @@
"bin": {
"playwright": "cli.js"
},
"devDependencies": {
"@zip.js/zip.js": "^2.3.17"
},
"engines": {
"node": ">=12"
}
@ -17948,7 +17945,6 @@
"playwright-core": {
"version": "file:packages/playwright-core",
"requires": {
"@zip.js/zip.js": "^2.3.17",
"commander": "^8.2.0",
"debug": "^4.1.1",
"extract-zip": "^2.0.1",

View File

@ -59,7 +59,7 @@ export class RecorderApp extends EventEmitter {
await this._page._setServerRequestInterceptor(async route => {
if (route.request().url().startsWith('https://playwright/')) {
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);
await route.fulfill({
status: 200,

View File

@ -38,7 +38,7 @@ export async function showTraceViewer(traceUrl: string, browserName: string, hea
server.routePrefix('/', (request, response) => {
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);
});

View File

@ -15,7 +15,7 @@ module.exports = {
output: {
globalObject: 'self',
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../../../lib/web/htmlReport')
path: path.resolve(__dirname, '../../../lib/webpack/htmlReport')
},
module: {
rules: [

View File

@ -15,7 +15,7 @@ module.exports = {
output: {
globalObject: 'self',
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../../../lib/web/recorder')
path: path.resolve(__dirname, '../../../lib/webpack/recorder')
},
module: {
rules: [

View File

@ -13,7 +13,7 @@ module.exports = {
output: {
globalObject: 'self',
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../../../lib/web/traceViewer')
path: path.resolve(__dirname, '../../../lib/webpack/traceViewer')
},
module: {
rules: [

View File

@ -15,7 +15,7 @@ module.exports = {
output: {
globalObject: 'self',
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../../../lib/web/traceViewer')
path: path.resolve(__dirname, '../../../lib/webpack/traceViewer')
},
module: {
rules: [
@ -45,7 +45,7 @@ module.exports = {
patterns: [
{
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'
},
],
}),

View File

@ -151,12 +151,12 @@ class HtmlBuilder {
fs.mkdirSync(this._dataFolder, { recursive: true });
// 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))
fs.copyFileSync(path.join(appFolder, file), path.join(this._reportFolder, file));
// 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');
fs.mkdirSync(traceViewerTargetFolder, { recursive: true });
// TODO (#9471): remove file filter when the babel build is fixed.

View File

@ -143,7 +143,13 @@ for (const packageDir of packages) {
continue;
steps.push({
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,
});
}