Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Manual Backport 2.x][@osd/pm] Automate multi-target bootstrap and build (#4650) #4860

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/osd-ace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
"name": "@osd/ace",
"version": "1.0.0",
"private": true,
"main": "./target/index.js",
"browser": "./target/web/index.js",
"main": "./target/web/index.js",
"types": "./target/types/index.d.ts",
"license": "Apache-2.0",
"scripts": {
"build": "../../scripts/use_node ./scripts/build.js",
"osd:bootstrap": "yarn build --dev"
},
"dependencies": {
"brace": "0.11.1"
},
Expand All @@ -17,5 +15,8 @@
"raw-loader": "^4.0.2",
"typescript": "4.0.2",
"webpack": "npm:@amoo-miki/webpack@4.46.0-rc.2"
},
"@osd/pm": {
"web": true
}
}
76 changes: 0 additions & 76 deletions packages/osd-ace/scripts/build.js

This file was deleted.

17 changes: 8 additions & 9 deletions packages/osd-ace/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./target",
"declaration": true,
"sourceMap": true,
"types": [
"jest",
"node"
]
"declarationDir": "./target/types",
"outDir": "./target",
"emitDeclarationOnly": true,
"stripInternal": true,
"declarationMap": true,
"types": ["jest", "node"]
},
"include": [
"src/**/*"
]
"include": ["./src/**/*"],
"exclude": ["target"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export function simpleOpenSearchDashboardsPlatformPluginDiscovery(
(acc: string[], dir) => [
...acc,
resolve(dir, '*/opensearch_dashboards.json'),
resolve(dir, '*/*/opensearch_dashboards.json'),
resolve(dir, '*/*/*/opensearch_dashboards.json'),
resolve(dir, '*/*/*/*/opensearch_dashboards.json'),
resolve(dir, '*/*/*/*/*/opensearch_dashboards.json'),
resolve(dir, '*/!(build)/opensearch_dashboards.json'),
resolve(dir, '*/!(build)/*/opensearch_dashboards.json'),
resolve(dir, '*/!(build)/*/*/opensearch_dashboards.json'),
resolve(dir, '*/!(build)/*/*/*/opensearch_dashboards.json'),
],
[]
),
Expand Down
9 changes: 4 additions & 5 deletions packages/osd-i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
"version": "1.0.0",
"license": "Apache-2.0",
"private": true,
"scripts": {
"build": "../../scripts/use_node scripts/build",
"osd:bootstrap": "../../scripts/use_node scripts/build --source-maps",
"osd:watch": "../../scripts/use_node scripts/build --watch --source-maps"
},
"devDependencies": {
"@babel/cli": "^7.16.0",
"@babel/core": "^7.16.5",
Expand All @@ -30,5 +25,9 @@
"prop-types": "^15.7.2",
"react": "^16.14.0",
"react-intl": "^2.8.0"
},
"@osd/pm": {
"node": true,
"web": true
}
}
105 changes: 0 additions & 105 deletions packages/osd-i18n/scripts/build.js

This file was deleted.

22 changes: 10 additions & 12 deletions packages/osd-i18n/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "./target/types",
"outDir": "./target",
"emitDeclarationOnly": true,
"stripInternal": true,
"declarationMap": true,
"types": ["jest", "node"]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"types/intl_format_cache.d.ts",
"types/intl_relativeformat.d.ts"
],
"exclude": [
"target"
],
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./target/types",
"types": [
"jest",
"node"
]
}
"exclude": ["target"]
}
12 changes: 9 additions & 3 deletions packages/osd-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,15 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
},
{
test: /\.(js|tsx?)$/,
// vega-lite and some of its dependencies don't have es5 builds
// so we need to build from source and transpile for webpack v4
exclude: /[\/\\]node_modules[\/\\](?!vega-(lite-next|label|functions)[\/\\])/,
exclude: [
/* vega-lite and some of its dependencies don't have es5 builds
* so we need to build from source and transpile for webpack v4
*/
/[\/\\]node_modules[\/\\](?!vega-(lite-next|label|functions)[\/\\])/,

// Don't attempt to look into release artifacts of the plugins
/[\/\\]plugins[\/\\][^\/\\]+[\/\\]build[\/\\]/,
],
use: {
loader: 'babel-loader',
options: {
Expand Down
21 changes: 21 additions & 0 deletions packages/osd-pm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,27 @@ The production build process relies on both the Grunt setup at the root of the
OpenSearch Dashboards project and code in `@osd/pm`. The full process is described in
`tasks/build/packages.js`.

## Targeted builds

Packages that are only compiled to CommonJS for consumption by server code, simply use a `tsconfig.json`
that extends the `tsconfig.base.json` found at the root of the project. Similarly, packages that need to be
compiled into ES modules, to be consumed in the browser and benefit from tree-shaking, use a`tsconfig.json`
that extends the `tsconfig.browser.json` available at the root of the project. However, some packages need
to be compiled for consumption by both server code and the browser. This can be achieved by retaining the
`tsconfig.json` and adding the following block to the `package.json` of the package:
```json
"@osd/pm": {
"node": true,
"web": true
}
```
With that, the relevant presets from `@osd/babel-preset` are applied to the code to produce bootstrap and
production build artifacts for the selected targets. It is acceptable to have only one target and that is
the same as setting the appropriate `extends` in the `tsconfig.json`.

Targeted builds call `babel` on the `src` folder and place artifacts into `target/node` and `target/web`
folders after calling `tsc` in the package root to generate type definitions.

## Development

This package is run from OpenSearch Dashboards root, using `yarn osd`. This will run the
Expand Down
Loading
Loading