Skip to content

Commit

Permalink
Build JS module only in development mode (#62398)
Browse files Browse the repository at this point in the history
Co-authored-by: kevin940726 <[email protected]>
Co-authored-by: gziolo <[email protected]>
  • Loading branch information
3 people authored Jun 13, 2024
1 parent 1e829be commit e0354b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions bin/packages/build-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const postcss = require( 'postcss' );
*/
const getBabelConfig = require( './get-babel-config' );

const isDev = process.env.NODE_ENV === 'development';

/**
* Path to packages directory.
*
Expand All @@ -27,10 +29,12 @@ const PACKAGES_DIR = path
*
* @type {Object}
*/
const JS_ENVIRONMENTS = {
main: 'build',
module: 'build-module',
};
const JS_ENVIRONMENTS = isDev
? { module: 'build-module' }
: {
main: 'build',
module: 'build-module',
};

/**
* Promisified fs.readFile.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@
"build:plugin-zip": "bash ./bin/build-plugin-zip.sh",
"clean:package-types": "tsc --build --clean && rimraf \"./packages/*/build-types\"",
"clean:packages": "rimraf \"./packages/*/@(build|build-module|build-style)\"",
"dev": "npm run build:packages && concurrently \"wp-scripts start\" \"npm run dev:packages\"",
"dev:packages": "concurrently \"node ./bin/packages/watch.js\" \"tsc --build --watch\"",
"dev": "cross-env NODE_ENV=development npm run build:packages && concurrently \"wp-scripts start\" \"npm run dev:packages\"",
"dev:packages": "cross-env NODE_ENV=development concurrently \"node ./bin/packages/watch.js\" \"tsc --build --watch\"",
"distclean": "git clean --force -d -X",
"docs:api-ref": "node ./bin/api-docs/update-api-docs.js",
"docs:blocks": "node ./bin/api-docs/gen-block-lib-list.js",
Expand Down

0 comments on commit e0354b6

Please sign in to comment.