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

Add Javascript and TypeScript build for jetpack-wpcom-mu #34158

Merged
merged 39 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
12335c0
Jetpack Mu WPcom: Migrate Error Handling
obenland Nov 16, 2023
9159934
Update script paths
obenland Nov 16, 2023
5900f65
Add initial JS build code for jetpack-mu-wpcom
daledupreez Nov 16, 2023
2f9d0c3
changelog
daledupreez Nov 16, 2023
56441c4
Loosen dependencies
daledupreez Nov 16, 2023
102379d
Add build/ to .gitignore
daledupreez Nov 16, 2023
de56417
Add clean script
daledupreez Nov 16, 2023
5135060
Add dependencies for error-reporting
daledupreez Nov 16, 2023
6f90e42
Update versions
daledupreez Nov 16, 2023
e1a1b30
Changelog
daledupreez Nov 16, 2023
1934951
Add build scripts
daledupreez Nov 16, 2023
aa4ff50
Try using PKG_DIR
obenland Nov 16, 2023
e9498ed
Add build/ directory to production output
daledupreez Nov 16, 2023
9c210ab
Import namespaced class
obenland Nov 16, 2023
55f4420
Merge branch 'add/js-build-for-jetpack-wpcom-mu' of https://github.co…
obenland Nov 16, 2023
bcf0831
Bail early if ETK has enqueued its script
obenland Nov 16, 2023
d606b39
Switch to more direct webpack build
daledupreez Nov 16, 2023
2edd95c
Remove @wordpress/scripts and dependencies
daledupreez Nov 16, 2023
284fd65
Ignore the .cache directory
daledupreez Nov 16, 2023
c0aa7a9
Update to using base dir and file to enqueue scripts
obenland Nov 16, 2023
f9e2410
Merge branch 'add/js-build-for-jetpack-wpcom-mu' of https://github.co…
obenland Nov 16, 2023
df9cb53
Remove JS/TS file exclusion and update build dir path
daledupreez Nov 16, 2023
c9ad3da
Ensure we set up production builds correctly
daledupreez Nov 16, 2023
232e5a9
Merge remote-tracking branch 'origin/trunk' into add/js-build-for-jet…
daledupreez Nov 16, 2023
90b72ea
Add docs for new build commands
obenland Nov 16, 2023
ec003ec
Better reflect folder structure
obenland Nov 16, 2023
13c5e76
Reset change pnpm-lock.yaml
daledupreez Nov 16, 2023
6d861f4
Update pnpm lock file
daledupreez Nov 16, 2023
f968f67
Update mu-wpcom-plugin
daledupreez Nov 16, 2023
9e0791f
Launchpad: Add `new_prompt` query param to Write first post task (#34…
sixhours Nov 16, 2023
2c0a191
Subscribe modal: remove filters and enable for Jetpack sites (#33909)
simison Nov 16, 2023
9ee445e
Merge branch 'trunk' into add/js-build-for-jetpack-wpcom-mu
daledupreez Nov 16, 2023
882158e
Add trailing slash
obenland Nov 16, 2023
348f3c4
Merge branch 'add/js-build-for-jetpack-wpcom-mu' of https://github.co…
obenland Nov 16, 2023
1696a90
Update build docs
daledupreez Nov 16, 2023
519deda
Merge branch 'trunk' into add/js-build-for-jetpack-wpcom-mu
okmttdhr Nov 24, 2023
7dbc2d0
Merge branch 'trunk' into add/js-build-for-jetpack-wpcom-mu
okmttdhr Dec 4, 2023
5ae7897
Update pnpm-lock.yaml
okmttdhr Dec 4, 2023
5e1e8c8
Update composer.lock
okmttdhr Dec 4, 2023
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
98 changes: 97 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions projects/packages/jetpack-mu-wpcom/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Files not needed to be distributed in the package.
.gitattributes export-ignore
.github/ export-ignore
package.json export-ignore
.gitattributes export-ignore
.github/ export-ignore
package.json export-ignore

# Files to include in the mirror repo, but excluded via gitignore
# Remember to end all directories with `/**` to properly tag every file.
# /src/js/example.min.js production-include
src/build/** production-include

# Files to exclude from the mirror repo, but included in the monorepo.
# Remember to end all directories with `/**` to properly tag every file.
Expand Down
2 changes: 2 additions & 0 deletions projects/packages/jetpack-mu-wpcom/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.cache/
src/build/
vendor/
node_modules/
wordpress/
25 changes: 25 additions & 0 deletions projects/packages/jetpack-mu-wpcom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@ If you plan on using this package in your WordPress plugin, we would recommend t

Need to report a security vulnerability? Go to [https://automattic.com/security/](https://automattic.com/security/) or directly to our security bug bounty site [https://hackerone.com/automattic](https://hackerone.com/automattic).

## Build System

_Note: `cd` to `projects/packages/jetpack-mu-wpcom` before running these commands_

- `npm run build-js`<br>
Compiles the plugins for development - the files are not minified and we produce a source map.

- `npm run build-production-js`<br>
Compiles the plugins for production - we produce minified files without source maps.

- `npm run clean`<br>
Removes all build files.

The entry point is:

- **Plugin**: `projects/packages/jetpack-mu-wpcom/src/features/{{feature-name}}/index.js`

The output is:

- **Plugin**: `/projects/packages/jetpack-mu-wpcom/src/build/{{feature-name}}/{{feature-name}}.js`

### Adding files to the build system

If you're adding a new feature that includes Javascript or Typescript, you will need to add the primary source file to the `entry` section in `projects/packages/jetpack-mu-wpcom/webpack.config.js`, where we'll use the key as the core file name, and the value as the primary input file for that module.

## License

jetpack-mu-wpcom is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add initial JS and TS build logic
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Added Editor error handling from ETK
4 changes: 2 additions & 2 deletions projects/packages/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"test-php": [
"@composer phpunit"
],
"build-production": "echo 'Add your build step to composer.json, please!'",
"build-development": "echo 'Add your build step to composer.json, please!'",
"build-production": "pnpm run build-production-js",
"build-development": "pnpm run build-js",
"post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy"
},
Expand Down
22 changes: 18 additions & 4 deletions projects/packages/jetpack-mu-wpcom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,24 @@
"author": "Automattic",
"scripts": {
"build": "echo 'Not implemented.'",
"build-js": "echo 'Not implemented.'",
"build-js": "pnpm clean && webpack",
"build-production": "echo 'Not implemented.'",
"build-production-js": "echo 'Not implemented.'",
"clean": "true"
"build-production-js": "NODE_ENV=production BABEL_ENV=production pnpm build-js",
"clean": "rm -rf src/build/"
},
"devDependencies": {}
"optionalDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@automattic/jetpack-webpack-config": "workspace:*",
"typescript": "^5.0.4",
"webpack": "5.76.0",
"webpack-cli": "4.9.1"
},
"dependencies": {
"@sentry/browser": "7.80.1",
"@wordpress/api-fetch": "6.42.0",
"@wordpress/hooks": "3.45.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Jetpack_Mu_Wpcom {

const PACKAGE_VERSION = '5.2.0-alpha';
const PKG_DIR = __DIR__ . '/../';
const BASE_DIR = __DIR__ . '/';
const BASE_FILE = __FILE__;

/**
* Initialize the class.
Expand Down Expand Up @@ -65,6 +67,8 @@ public static function load_features() {
require_once __DIR__ . '/features/100-year-plan/enhanced-ownership.php';
require_once __DIR__ . '/features/100-year-plan/locked-mode.php';

require_once __DIR__ . '/features/error-reporting/error-reporting.php';

require_once __DIR__ . '/features/media/heif-support.php';

require_once __DIR__ . '/features/block-patterns/block-patterns.php';
Expand Down
Loading
Loading