Skip to content

Commit 8ffe365

Browse files
Merge pull request google#10321 from google/infra/10092-npm-workspaces-assets
Move JS dependencies required to build assets into their own workspace
2 parents 28ec42d + 6ef79f8 commit 8ffe365

39 files changed

+531
-482
lines changed

.github/workflows/e2e-tests.yml

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ on:
1414
- '.github/workflows/e2e-tests.yml'
1515
- '.babelrc'
1616
- 'assets/**'
17-
- 'blocks/**'
1817
- 'includes/**'
1918
- '/*.php'
2019
- 'jest-puppeteer.config.js'
@@ -47,7 +46,6 @@ on:
4746
- '.github/workflows/e2e-tests.yml'
4847
- '.babelrc'
4948
- 'assets/**'
50-
- 'blocks/**'
5149
- 'includes/**'
5250
- '/*.php'
5351
- 'jest-puppeteer.config.js'

.github/workflows/storybook.yml

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212
- '!assets/**/__tests__/**/*.js'
1313
- '!assets/**/test/*.js'
1414
- '!assets/**/*.test.js'
15-
- 'blocks/**'
1615
- 'storybook/**'
1716
- '**.scss'
1817
- '.nvmrc'
@@ -30,7 +29,6 @@ on:
3029
- '!assets/**/__tests__/**/*.js'
3130
- '!assets/**/test/*.js'
3231
- '!assets/**/*.test.js'
33-
- 'blocks/**'
3432
- 'storybook/**'
3533
- '**.scss'
3634
- '.nvmrc'

.github/workflows/visual-regression.yml

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ on:
1313
- '!assets/**/__tests__/**/*.js'
1414
- '!assets/**/test/*.js'
1515
- '!assets/**/*.test.js'
16-
- 'blocks/**'
1716
- '**.stories.js'
1817
- 'tests/backstop/**'
1918
- 'storybook/**'

.github/workflows/zips.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ on:
1515
- '!assets/**/__tests__/**/*.js'
1616
- '!assets/**/test/*.js'
1717
- '!assets/**/*.test.js'
18-
- 'blocks/**'
1918
- 'includes/**'
2019
- 'google-site-kit.php'
2120
- 'scoper.inc.php'
@@ -42,7 +41,6 @@ on:
4241
- '!assets/**/__tests__/**/*.js'
4342
- '!assets/**/test/*.js'
4443
- '!assets/**/*.test.js'
45-
- 'blocks/**'
4644
- 'includes/**'
4745
- 'google-site-kit.php'
4846
- 'scoper.inc.php'
@@ -108,6 +106,11 @@ jobs:
108106
with:
109107
node-version-file: '.nvmrc'
110108
cache: 'npm'
109+
# nvm@7 is the minimum version required for npm workspace support.
110+
# This is needed to prevent js lint failures due to module resolution to the workspace packages.
111+
# This can be removed once our node base version comes with nvm@7 or greater.
112+
- name: Install npm Globally
113+
run: npm run install-global-npm
111114
- name: npm install
112115
run: |
113116
npm ci

blocks/reader-revenue-manager/block-editor-plugin/SettingPanel.js assets/blocks/reader-revenue-manager/block-editor-plugin/SettingPanel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { PluginDocumentSettingPanel as EditorSettingPanel } from '@wordpress-cor
2626
/**
2727
* Internal dependencies
2828
*/
29-
import GoogleLogoIcon from '../../../assets/svg/graphics/logo-g.svg';
29+
import GoogleLogoIcon from '../../../svg/graphics/logo-g.svg';
3030
import SettingsForm from './SettingsForm';
3131

3232
export default function SettingPanel() {

blocks/reader-revenue-manager/block-editor-plugin/SettingsForm.js assets/blocks/reader-revenue-manager/block-editor-plugin/SettingsForm.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { useState } from '@wordpress-core/element';
2727
* Internal dependencies
2828
*/
2929
import Data from 'googlesitekit-data';
30-
import { MODULES_READER_REVENUE_MANAGER } from '../../../assets/js/modules/reader-revenue-manager/datastore/constants';
30+
import { MODULES_READER_REVENUE_MANAGER } from '../../../js/modules/reader-revenue-manager/datastore/constants';
3131
import { CORE_EDITOR } from '../common/constants';
3232

3333
const { select, dispatch } = Data;

blocks/reader-revenue-manager/block-editor-plugin/plugin-registration.js assets/blocks/reader-revenue-manager/block-editor-plugin/plugin-registration.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import { registerPlugin } from '@wordpress-core/plugins';
2525
* Internal dependencies
2626
*/
2727
import Data from 'googlesitekit-data';
28-
import { CORE_MODULES } from '../../../assets/js/googlesitekit/modules/datastore/constants';
29-
import { CORE_USER } from '../../../assets/js/googlesitekit/datastore/user/constants';
28+
import { CORE_MODULES } from '../../../js/googlesitekit/modules/datastore/constants';
29+
import { CORE_USER } from '../../../js/googlesitekit/datastore/user/constants';
3030
import { CORE_EDIT_SITE } from '../common/constants';
31-
import { MODULES_READER_REVENUE_MANAGER } from '../../../assets/js/modules/reader-revenue-manager/datastore/constants';
31+
import { MODULES_READER_REVENUE_MANAGER } from '../../../js/modules/reader-revenue-manager/datastore/constants';
3232
import SettingPanel from './SettingPanel';
3333

3434
const { select, resolveSelect } = Data;

blocks/reader-revenue-manager/block-editor-plugin/plugin-registration.test.js assets/blocks/reader-revenue-manager/block-editor-plugin/plugin-registration.test.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,15 @@ jest.mock( '@wordpress-core/editor', () => ( {} ), {
3535
jest.mock( '@wordpress-core/components', () => ( {} ), {
3636
virtual: true,
3737
} );
38-
jest.mock( '@wordpress-core/editor', () => ( {} ), { virtual: true } );
3938
jest.mock( '@wordpress-core/element', () => ( {} ), { virtual: true } );
4039

4140
import Data from 'googlesitekit-data';
4241
import SettingPanel from './SettingPanel';
43-
import { MODULES_READER_REVENUE_MANAGER } from '../../../assets/js/modules/reader-revenue-manager/datastore/constants';
44-
import { registerStore as registerCoreModulesStore } from '../../../assets/js/googlesitekit/modules';
45-
import { registerStore as registerCoreUserStore } from '../../../assets/js/googlesitekit/datastore/user';
46-
import { registerStore as registerReaderRevenueManagerStore } from '../../../assets/js/modules/reader-revenue-manager/datastore';
47-
import { provideModules, provideUserInfo } from '../../../tests/js/utils';
42+
import { MODULES_READER_REVENUE_MANAGER } from '../../../js/modules/reader-revenue-manager/datastore/constants';
43+
import { registerStore as registerCoreModulesStore } from '../../../js/googlesitekit/modules';
44+
import { registerStore as registerCoreUserStore } from '../../../js/googlesitekit/datastore/user';
45+
import { registerStore as registerReaderRevenueManagerStore } from '../../../js/modules/reader-revenue-manager/datastore';
46+
import { provideModules, provideUserInfo } from '../../../../tests/js/utils';
4847
import { registerPlugin } from '@wordpress-core/plugins';
4948
import { registerReaderRevenueManagerPlugin } from './plugin-registration';
5049

blocks/reader-revenue-manager/common/ButtonEdit.js assets/blocks/reader-revenue-manager/common/ButtonEdit.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import { useSelect } from '@wordpress-core/data';
3333
import { select, resolveSelect } from 'googlesitekit-data';
3434
import EditorButton from './EditorButton';
3535
import { CORE_EDITOR } from './constants';
36-
import { CORE_MODULES } from '../../../assets/js/googlesitekit/modules/datastore/constants';
37-
import { MODULES_READER_REVENUE_MANAGER } from '../../../assets/js/modules/reader-revenue-manager/datastore/constants';
36+
import { CORE_MODULES } from '../../../js/googlesitekit/modules/datastore/constants';
37+
import { MODULES_READER_REVENUE_MANAGER } from '../../../js/modules/reader-revenue-manager/datastore/constants';
3838
import { getNoticeAndDisabled } from './button-edit-utils';
3939

4040
/**

blocks/reader-revenue-manager/common/EditorButton.js assets/blocks/reader-revenue-manager/common/EditorButton.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import PropTypes from 'prop-types';
2323
/**
2424
* Internal dependencies
2525
*/
26-
import GoogleLogoIcon from '../../../assets/svg/graphics/logo-g.svg';
26+
import GoogleLogoIcon from '../../../svg/graphics/logo-g.svg';
2727

2828
export default function EditorButton( { children, disabled } ) {
2929
return (

blocks/reader-revenue-manager/common/editor-styles.scss assets/blocks/reader-revenue-manager/common/editor-styles.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
@import "../../../assets/sass/config/variables";
19+
@import "../../../sass/config/variables";
2020

2121
// Styles copied over from the actual inline button.
2222
.googlesitekit-blocks-reader-revenue-manager-button {

blocks/reader-revenue-manager/contribute-with-google/Edit.js assets/blocks/reader-revenue-manager/contribute-with-google/Edit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { __ } from '@wordpress/i18n';
2626
*/
2727
import { select } from 'googlesitekit-data';
2828
import { ButtonEdit } from '../common';
29-
import { MODULES_READER_REVENUE_MANAGER } from '../../../assets/js/modules/reader-revenue-manager/datastore/constants';
29+
import { MODULES_READER_REVENUE_MANAGER } from '../../../js/modules/reader-revenue-manager/datastore/constants';
3030

3131
/**
3232
* Contribute with Google Block Edit component.

blocks/reader-revenue-manager/contribute-with-google/index.js assets/blocks/reader-revenue-manager/contribute-with-google/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import { registerBlockType } from '@wordpress-core/blocks';
2323
* Internal dependencies
2424
*/
2525
import { select, resolveSelect } from 'googlesitekit-data';
26-
import { CORE_MODULES } from '../../../assets/js/googlesitekit/modules/datastore/constants';
27-
import { CORE_USER } from '../../../assets/js/googlesitekit/datastore/user/constants';
28-
import { MODULES_READER_REVENUE_MANAGER } from '../../../assets/js/modules/reader-revenue-manager/datastore/constants';
26+
import { CORE_MODULES } from '../../../js/googlesitekit/modules/datastore/constants';
27+
import { CORE_USER } from '../../../js/googlesitekit/datastore/user/constants';
28+
import { MODULES_READER_REVENUE_MANAGER } from '../../../js/modules/reader-revenue-manager/datastore/constants';
2929
import { CORE_EDIT_SITE } from '../common/constants';
3030
import Edit from './Edit';
3131
import metadata from './block.json';

blocks/reader-revenue-manager/subscribe-with-google/Edit.js assets/blocks/reader-revenue-manager/subscribe-with-google/Edit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { __ } from '@wordpress/i18n';
2626
*/
2727
import { select } from 'googlesitekit-data';
2828
import { ButtonEdit } from '../common';
29-
import { MODULES_READER_REVENUE_MANAGER } from '../../../assets/js/modules/reader-revenue-manager/datastore/constants';
29+
import { MODULES_READER_REVENUE_MANAGER } from '../../../js/modules/reader-revenue-manager/datastore/constants';
3030

3131
/**
3232
* Subscribe with Google Block Edit component.

blocks/reader-revenue-manager/subscribe-with-google/index.js assets/blocks/reader-revenue-manager/subscribe-with-google/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import { registerBlockType } from '@wordpress-core/blocks';
2323
* Internal dependencies
2424
*/
2525
import { select, resolveSelect } from 'googlesitekit-data';
26-
import { CORE_MODULES } from '../../../assets/js/googlesitekit/modules/datastore/constants';
27-
import { CORE_USER } from '../../../assets/js/googlesitekit/datastore/user/constants';
28-
import { MODULES_READER_REVENUE_MANAGER } from '../../../assets/js/modules/reader-revenue-manager/datastore/constants';
26+
import { CORE_MODULES } from '../../../js/googlesitekit/modules/datastore/constants';
27+
import { CORE_USER } from '../../../js/googlesitekit/datastore/user/constants';
28+
import { MODULES_READER_REVENUE_MANAGER } from '../../../js/modules/reader-revenue-manager/datastore/constants';
2929
import { CORE_EDIT_SITE } from '../common/constants';
3030
import Edit from './Edit';
3131
import metadata from './block.json';
File renamed without changes.
File renamed without changes.
File renamed without changes.

assets/package.json

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
{
2+
"scripts": {
3+
"build": "npm run build:production",
4+
"prebuild:dev": "npm run remove-dist",
5+
"build:dev": "webpack --mode=development --devtool cheap-module-eval-source-map --output-pathinfo",
6+
"prebuild:production": "npm run remove-dist",
7+
"build:production": "webpack --mode=production",
8+
"build:test": "npm run build:production -- --include-tests",
9+
"watch": "npm run build:dev -- --watch",
10+
"remove-dist": "rimraf ../dist"
11+
},
12+
"browserslist": [
13+
"extends @wordpress/browserslist-config"
14+
],
15+
"dependencies": {
16+
"@lit-labs/react": "^1.2.0",
17+
"@material-ui/core": "^4.11.4",
18+
"@material/button": "^2.3.0",
19+
"@material/checkbox": "^2.3.0",
20+
"@material/dialog": "^2.3.0",
21+
"@material/form-field": "^2.3.0",
22+
"@material/layout-grid": "^0.41.0",
23+
"@material/linear-progress": "^1.1.0",
24+
"@material/list": "^2.3.0",
25+
"@material/menu": "^2.3.0",
26+
"@material/radio": "^2.3.0",
27+
"@material/react-card": "^0.15.0",
28+
"@material/react-chips": "^0.15.0",
29+
"@material/react-dialog": "^0.15.0",
30+
"@material/react-select": "^0.15.0",
31+
"@material/react-tab-bar": "^0.15.0",
32+
"@material/react-text-field": "^0.15.0",
33+
"@material/ripple": "^2.3.0",
34+
"@material/select": "^2.3.1",
35+
"@material/switch": "^2.3.0",
36+
"@material/textfield": "^2.3.1",
37+
"@material/theme": "^1.1.0",
38+
"@material/web": "^1.0.0-pre.9",
39+
"@reach/combobox": "^0.10.5",
40+
"@react-hook/event": "^1.2.1",
41+
"@react-hook/merged-ref": "^1.3.0",
42+
"@react-hook/throttle": "^2.2.0",
43+
"@wordpress/api-fetch": "^3.18.0",
44+
"@wordpress/compose": "^3.25.3",
45+
"@wordpress/data": "^4.27.3",
46+
"@wordpress/dom-ready": "^2.10.0",
47+
"@wordpress/element": "^2.20.3",
48+
"@wordpress/i18n": "^3.14.0",
49+
"@wordpress/icons": "^2.9.0",
50+
"@wordpress/keycodes": "^3.2.4",
51+
"@wordpress/url": "^3.1.1",
52+
"classnames": "^2.2.6",
53+
"clipboard-copy": "^3.1.0",
54+
"compare-versions": "^3.6.0",
55+
"dompurify": "^2.5.8",
56+
"focus-trap-react": "^10.0.0",
57+
"immer": "^9.0.15",
58+
"intersection-observer": "^0.12.0",
59+
"invariant": "^2.2.4",
60+
"just-detect-adblock": "^1.1.0",
61+
"lodash": "^4.17.21",
62+
"md5": "^2.2.1",
63+
"memize": "^1.1.0",
64+
"prop-types": "^15.7.2",
65+
"psl": "^1.8.0",
66+
"punycode": "^2.1.1",
67+
"query-string": "^7.0.1",
68+
"react": "^16.14.0",
69+
"react-dom": "^16.14.0",
70+
"react-google-charts": "^3.0.15",
71+
"react-joyride": "^2.9.3",
72+
"react-router-dom": "^5.2.0",
73+
"react-use": "^15.3.4",
74+
"react-use-observer": "^2.2.4",
75+
"use-memo-one": "^1.1.2"
76+
},
77+
"devDependencies": {
78+
"@babel/core": "^7.14.8",
79+
"@babel/plugin-transform-runtime": "^7.10.4",
80+
"@babel/preset-react": "^7.10.4",
81+
"@svgr/webpack": "^5.4.0",
82+
"@wordpress/babel-preset-default": "^4.17.0",
83+
"@wordpress/browserslist-config": "^5.40.0",
84+
"@wordpress/eslint-plugin": "^7.1.0",
85+
"@wordpress/prettier-config": "^2.0",
86+
"@wordpress/stylelint-config": "^21.0.0",
87+
"autoprefixer": "^9.8.5",
88+
"babel-loader": "^8.1.0",
89+
"circular-dependency-plugin": "^5.2.0",
90+
"copy-webpack-plugin": "^6.4.1",
91+
"create-file-webpack": "^1.0.2",
92+
"css-loader": "^3.6.0",
93+
"cssnano": "^4.1.10",
94+
"eslint": "^7.32.0",
95+
"eslint-import-resolver-alias": "^1.1.2",
96+
"eslint-plugin-filenames": "^1.3.2",
97+
"eslint-plugin-import": "^2.25.3",
98+
"eslint-plugin-jsdoc": "^30.7.13",
99+
"eslint-plugin-lodash": "^7.4.0",
100+
"eslint-plugin-react-hooks": "^4.2.0",
101+
"eslint-plugin-sitekit": "file:../packages/eslint-plugin",
102+
"eslint-scope": "^5.1.0",
103+
"eslint-webpack-plugin": "^2.5.1",
104+
"glob-to-regexp": "^0.4.1",
105+
"google-pax-sdk": "1.1.0",
106+
"mini-css-extract-plugin": "^1.2.1",
107+
"natives": "^1.1.6",
108+
"patch-package": "^8.0.0",
109+
"postcss": "^8.4.31",
110+
"postcss-import-url": "^7.0.0",
111+
"postcss-loader": "^4.0.0",
112+
"postcss-preset-env": "^9.5.11",
113+
"prettier": "npm:[email protected]",
114+
"rimraf": "^3.0.2",
115+
"sass": "^1.30.0",
116+
"sass-loader": "^9.0.2",
117+
"semver-compare": "^1.0.0",
118+
"semver-regex": "^3.1.4",
119+
"stylelint": "^14.11.0",
120+
"stylelint-config-standard-scss": "^5.0.0",
121+
"stylelint-declaration-strict-value": "^1.9.0",
122+
"stylelint-order": "^5.0.0",
123+
"stylelint-scss": "^4.3.0",
124+
"terser-webpack-plugin": "^3.0.6",
125+
"webpack": "^4.43.0",
126+
"webpack-bundle-analyzer": "^4.6.1",
127+
"webpack-cli": "^3.3.12",
128+
"webpack-manifest-plugin": "^2.2.0",
129+
"webpackbar": "^4.0.0"
130+
}
131+
}

webpack.config.js assets/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* Internal dependencies
2121
*/
22-
const { createRules } = require( './webpack/common' );
22+
const { createRules } = require( '../webpack/common' );
2323
const adminCssConfig = require( './webpack/adminCss.config' );
2424
const basicModulesConfig = require( './webpack/basicModules.config' );
2525
const frontendModules = require( './webpack/frontendModules.config' );

webpack/adminCss.config.js assets/webpack/adminCss.config.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ const WebpackBar = require( 'webpackbar' );
2626
/**
2727
* Internal dependencies
2828
*/
29-
const { manifestArgs } = require( './common' );
29+
const { rootDir, manifestArgs } = require( '../../webpack/common' );
3030

3131
module.exports = ( mode ) => ( {
3232
entry: {
33-
'googlesitekit-admin-css': './assets/sass/admin.scss',
34-
'googlesitekit-adminbar-css': './assets/sass/adminbar.scss',
35-
'googlesitekit-wp-dashboard-css': './assets/sass/wpdashboard.scss',
33+
'googlesitekit-admin-css': './sass/admin.scss',
34+
'googlesitekit-adminbar-css': './sass/adminbar.scss',
35+
'googlesitekit-wp-dashboard-css': './sass/wpdashboard.scss',
3636
'googlesitekit-authorize-application-css':
37-
'./assets/sass/authorize-application.scss',
37+
'./sass/authorize-application.scss',
38+
},
39+
output: {
40+
path: rootDir + '/dist',
3841
},
3942
module: {
4043
rules: [
@@ -49,7 +52,7 @@ module.exports = ( mode ) => ( {
4952
options: {
5053
implementation: require( 'sass' ),
5154
sassOptions: {
52-
includePaths: [ 'node_modules' ],
55+
includePaths: [ rootDir + '/node_modules' ],
5356
},
5457
},
5558
},

webpack/basicModules.config.js assets/webpack/basicModules.config.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ const {
3131
externals,
3232
resolve,
3333
rules,
34-
} = require( './common' );
34+
} = require( '../../webpack/common' );
3535

3636
module.exports = ( mode ) => ( {
3737
entry: {
38-
'googlesitekit-i18n': './assets/js/googlesitekit-i18n.js',
38+
'googlesitekit-i18n': './js/googlesitekit-i18n.js',
3939
// Analytics advanced tracking script to be injected in the frontend.
40-
'analytics-advanced-tracking':
41-
'./assets/js/analytics-advanced-tracking.js',
40+
'analytics-advanced-tracking': './js/analytics-advanced-tracking.js',
4241
},
4342
externals,
4443
output: {

0 commit comments

Comments
 (0)