-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Introduce shared webpack config; Use webpack to build compass C…
…OMPASS-4776 (#2454) * feat(scripts): Support configs in create-workspace; Fix total counter * feat(@mongodb-js/webpack-config-compass): Add new shared webpack configuration for Compass and plugins * build(mongodb-compass): Use webpack-config-compass to bundle application source instead of hadron-compile-cache, hadron-module-cache, hadron-style-manager * feat(@mongodb-js/hadron-plugin-manager): Make plugin manager compatible with webpack; Simplify plugin resolution logic All plugins in pluginList are now always resolved using node_modules resolution logic, no fallbacks to relative paths * build(@mongodb-js/compass-serverstats): Refactor serverstats plugin to use new webpack config * chore: Remove all unused styles/index.less files They were needed while compass was using style-manager, but can be safely removed now, most of them were just empty files * chore(hadron-build): Remove all release steps that are handled by webpack now * chore: Remove unused and archived hadron-style-manager, hadron-compile-cache, and hadron-module-cache packages from the monorepo * chore: Update package-lock * fix(hadron-plugin-manager): Fix depcheck error * fix(hadron-build): Ignore failed meta resolution if it happened for the dev or optional dep * chore(mongodb-compass): Simplify `electronBinary` declaration Co-authored-by: Anna Henningsen <[email protected]> * fix(mongodb-compass): Set charset to utf-8 on Compass html pages * fix(mongodb-compass, @mongodb-js/compass-serverstats): Use `pathToFileURL` so that filepaths are always properly encoded Co-authored-by: Anna Henningsen <[email protected]> * fix(mongodb-compass, hadron-build, compass-e2e-tests): Run webpack with hadron-build for consistency; Ease propType check on the Stage component * fix(@mongodb-js/webpack-config-compass): Ignore eslint warning * fix(hadron-build): Fix eslint errors * fix(compass-e2e-tests): Fix prettier formatting * feat(@mongodb-js/mocha-config-compass): Add support for mocha-electron and a special compass plugin configuration * chore(@mongodb-js/webpack-config-compass): Update dependencies * chore(compass-serverstats): Refactor plugin to use new mocha test setup * chore: UPdare package-lock and ignore more webpack dependencies (for now) * fix(mongodb-compass): Allow self in img src content security policy This is needed so in dev/serve mode images can be loaded, it's also safe to do for prod * fix(webpack-config-compass): Always provide a library output for a renderer plugin build Co-authored-by: Anna Henningsen <[email protected]> Co-authored-by: Anna Henningsen <[email protected]>
- Loading branch information
1 parent
3e2bf2f
commit f7c5816
Showing
164 changed files
with
108,960 additions
and
95,321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ignores: | ||
# TODO: See package.json. Remove when all packages using the same webpack version | ||
- '@webpack-cli/serve' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
...require('./react'), | ||
// electron-mocha config options (ignored when run with just mocha) | ||
// https://github.com/jprichardson/electron-mocha | ||
renderer: true, | ||
windowConfig: path.resolve(__dirname, 'window-config.json'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
const path = require('path'); | ||
const base = require('./'); | ||
const base = require('.'); | ||
|
||
const pkgJson = require(path.join(process.cwd(), 'package.json')); | ||
|
||
const isEnzyme = !!pkgJson.devDependencies.enzyme; | ||
|
||
module.exports = { | ||
...base, | ||
require: base.require.concat([ | ||
'jsdom-global/register', | ||
path.resolve(__dirname, 'chai-dom-register.js'), | ||
]), | ||
require: base.require.concat( | ||
[ | ||
path.resolve(__dirname, 'register', 'jsdom-global-register.js'), | ||
path.resolve(__dirname, 'register', 'chai-dom-register.js'), | ||
path.resolve(__dirname, 'register', 'css-import-register.js'), | ||
// We want to move new components/plugins to use testing-library, but for | ||
// compat reasons will register and activate enzyme with adapters if | ||
// plugin is using it | ||
isEnzyme && path.resolve(__dirname, 'register', 'enzyme-register.js'), | ||
].filter(Boolean) | ||
), | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const identityObjProxy = require('identity-obj-proxy'); | ||
|
||
const identityProxyExports = (module) => { | ||
module.exports = identityObjProxy; | ||
}; | ||
|
||
require.extensions['.css'] = identityProxyExports; | ||
require.extensions['.less'] = identityProxyExports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const chai = require('chai'); | ||
const Enzyme = require('enzyme'); | ||
const Adapter = require('enzyme-adapter-react-16'); | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
chai.use(require('chai-enzyme')()); |
3 changes: 3 additions & 0 deletions
3
configs/mocha-config-compass/register/jsdom-global-register.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if (typeof window === 'undefined') { | ||
require('jsdom-global/register'); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require('ts-node').register({ | ||
files: true, | ||
transpileOnly: true, | ||
compilerOptions: { | ||
allowJs: true, | ||
jsx: 'react', | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"webPreferences": { | ||
"subpixel-font-scaling": true, | ||
"direct-write": true, | ||
"nodeIntegration": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
ignores: | ||
- '@mongodb-js/prettier-config-compass' | ||
- '@mongodb-js/tsconfig-compass' | ||
- '@types/chai' | ||
- '@types/sinon-chai' | ||
- 'sinon' | ||
# peerdep | ||
- 'core-js' | ||
# peerdep | ||
- 'postcss' | ||
# used implicitly by the bin/webpack file | ||
- 'webpack-cli' | ||
# recursive | ||
- 'mongodb-compass' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.nyc-output | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['@mongodb-js/eslint-config-compass'], | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ['./tsconfig-lint.json'], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.nyc-output | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"@mongodb-js/prettier-config-compass" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env node | ||
|
||
// XXX: This mimics (simplified) webpack behavior, but makes sure that we are | ||
// always resolving webpack-cli relative to the config. It is required to do, to | ||
// avoid hoisting issues that can try to start e.g., webpack-dev-server with | ||
// an unsupported version due to some webpack deps being hoisted and some not | ||
// (also allows other packages to avoid depending on those) | ||
// | ||
// This can be removed immediately after we are done moving other plugins to the | ||
// new webpack configuration. | ||
const path = require('path'); | ||
process.env.WEBPACK_CLI_SKIP_IMPORT_LOCAL = true; | ||
// TODO: This doesn't work until https://github.com/webpack/webpack-cli/pull/2907 is published | ||
// process.env.WEBPACK_PACKAGE = path.dirname( | ||
// require.resolve('webpack/package.json') | ||
// ); | ||
// process.env.WEBPACK_DEV_SERVER_PACKAGE = path.dirname( | ||
// require.resolve('webpack-dev-server/package.json') | ||
// ); | ||
const pkgPath = require.resolve(`webpack-cli/package.json`); | ||
const pkg = require(pkgPath); | ||
require(path.resolve(path.dirname(pkgPath), pkg.bin['webpack-cli'])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"name": "@mongodb-js/webpack-config-compass", | ||
"description": "Shared webpack configuration for Compass application and plugins", | ||
"author": { | ||
"name": "MongoDB Inc", | ||
"email": "[email protected]" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bugs": { | ||
"url": "https://jira.mongodb.org/projects/COMPASS/issues", | ||
"email": "[email protected]" | ||
}, | ||
"homepage": "https://github.com/mongodb-js/compass", | ||
"version": "0.1.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mongodb-js/compass.git" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"license": "SSPL", | ||
"main": "dist/index.js", | ||
"bin": { | ||
"webpack-compass": "./bin/webpack.js" | ||
}, | ||
"exports": { | ||
"require": "./dist/index.js", | ||
"import": "./dist/.esm-wrapper.mjs" | ||
}, | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"bootstrap": "npm run compile", | ||
"prepublishOnly": "npm run compile", | ||
"compile": "tsc -p tsconfig.json", | ||
"postcompile": "gen-esm-wrapper . ./dist/.esm-wrapper.mjs", | ||
"eslint": "eslint", | ||
"prettier": "prettier", | ||
"lint": "npm run eslint . && npm run prettier -- --check .", | ||
"depcheck": "depcheck", | ||
"check": "npm run lint && npm run depcheck", | ||
"check-ci": "npm run check", | ||
"reformat": "npm run prettier -- --write ." | ||
}, | ||
"devDependencies": { | ||
"@mongodb-js/eslint-config-compass": "^0.3.0", | ||
"@mongodb-js/prettier-config-compass": "^0.2.0", | ||
"@mongodb-js/tsconfig-compass": "^0.2.0", | ||
"@types/html-webpack-plugin": "^3.2.6", | ||
"depcheck": "^1.4.1", | ||
"eslint": "^7.25.0", | ||
"prettier": "2.3.2", | ||
"typescript": "^4.3.5" | ||
}, | ||
"dependencies": { | ||
"@babel/core": "^7.15.5", | ||
"@babel/plugin-proposal-decorators": "^7.15.4", | ||
"@babel/preset-env": "^7.15.6", | ||
"@babel/preset-react": "^7.14.5", | ||
"@babel/preset-typescript": "^7.15.0", | ||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.0", | ||
"babel-loader": "^8.2.2", | ||
"core-js": "^3.17.3", | ||
"css-loader": "^4.3.0", | ||
"electron": "6.1.12", | ||
"html-webpack-plugin": "^5.3.2", | ||
"less-loader": "^10.0.1", | ||
"node-loader": "^2.0.0", | ||
"postcss": "^8.3.6", | ||
"postcss-loader": "^6.1.1", | ||
"postcss-preset-env": "^6.7.0", | ||
"react-refresh": "^0.10.0", | ||
"style-loader": "^3.2.1", | ||
"webpack": "^5.52.1", | ||
"webpack-cli": "^4.8.0", | ||
"webpack-dev-server": "^4.2.1", | ||
"webpack-merge": "^5.8.0" | ||
} | ||
} |
Oops, something went wrong.