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

Do not transpile JS packages twice #44824

Merged
merged 6 commits into from Nov 3, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions client/webpack.config.desktop.js
Expand Up @@ -83,6 +83,7 @@ module.exports = {
],
resolve: {
extensions: [ '.json', '.js', '.jsx', '.ts', '.tsx' ],
mainFields: [ 'calypso:src', 'module', 'main' ],
modules: [ __dirname, 'node_modules' ],
alias: {
config: 'server/config',
Expand Down
1 change: 1 addition & 0 deletions client/webpack.config.js
Expand Up @@ -256,6 +256,7 @@ const webpackConfig = {
},
resolve: {
extensions: [ '.json', '.js', '.jsx', '.ts', '.tsx' ],
mainFields: [ 'browser', 'calypso:src', 'module', 'main' ],
modules: [ __dirname, 'node_modules' ],
alias: Object.assign(
{
Expand Down
2 changes: 2 additions & 0 deletions client/webpack.config.node.js
Expand Up @@ -59,6 +59,7 @@ function getMonorepoPackages() {
*
* @returns {Array} list of externals
*/

function getExternals() {
return [
// Don't bundle any node_modules, both to avoid a massive bundle, and problems
Expand Down Expand Up @@ -144,6 +145,7 @@ const webpackConfig = {
},
resolve: {
extensions: [ '.json', '.js', '.jsx', '.ts', '.tsx' ],
mainFields: [ 'calypso:src', 'module', 'main' ],
modules: [ __dirname, path.join( __dirname, 'extensions' ), 'node_modules' ],
alias: {
'calypso/config': 'server/config',
Expand Down
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be nice to move to some shared preset. The packages' Jest configs are getting repetitive: the cacheDirectory is always the same, and now the resolver field is, too.

By the way, even the rootDir field could be removed one day, when this Jest bug gets fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out how to do it. When I added the cacheDirectory to the base jest config I got some problems relative to how jest resolves paths... I don't remember the details, I'll try again.

Copy link
Contributor Author

@scinos scinos Oct 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a separate PR for it: #46953

};
1 change: 1 addition & 0 deletions packages/calypso-analytics/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/calypso-build/webpack.config.js
Expand Up @@ -132,6 +132,7 @@ function getWebpackConfig(
},
resolve: {
extensions: [ '.json', '.js', '.jsx', '.ts', '.tsx' ],
mainFields: [ 'browser', 'calypso:src', 'module', 'main' ],
modules: [ 'node_modules' ],
},
node: false,
Expand Down
1 change: 1 addition & 0 deletions packages/calypso-codemods/jest.config.js
Expand Up @@ -4,4 +4,5 @@ module.exports = {
testMatch: [ '<rootDir>/tests/*/codemod.spec.js' ],
setupFiles: [ '<rootDir>/setup-tests.js' ],
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/components/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/composite-checkout/jest.config.js
Expand Up @@ -4,4 +4,5 @@ module.exports = {
testEnvironment: 'jsdom',
globals: { window: { navigator: { userAgent: 'jest' } } },
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
5 changes: 4 additions & 1 deletion packages/composite-checkout/webpack.config.demo.js
Expand Up @@ -18,7 +18,10 @@ module.exports = {
},
],
},
resolve: { extensions: [ '*', '.js', '.jsx' ] },
resolve: {
extensions: [ '*', '.js', '.jsx' ],
mainFields: [ 'browser', 'calypso:src', 'module', 'main' ],
},
output: {
path: path.resolve( __dirname, '/dist/' ),
publicPath: '/dist/',
Expand Down
5 changes: 4 additions & 1 deletion packages/composite-checkout/webpack.config.js
Expand Up @@ -27,7 +27,10 @@ module.exports = {
},
],
},
resolve: { extensions: [ '*', '.js', '.jsx' ] },
resolve: {
extensions: [ '*', '.js', '.jsx' ],
mainFields: [ 'browser', 'calypso:src', 'module', 'main' ],
},
output: {
path: path.resolve( __dirname, 'dist/' ),
publicPath: '/dist/',
Expand Down
1 change: 1 addition & 0 deletions packages/data-stores/jest.config.js
Expand Up @@ -3,4 +3,5 @@ module.exports = {
rootDir: __dirname,
setupFiles: [ 'regenerator-runtime/runtime' ],
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/domain-picker/jest.config.js
Expand Up @@ -6,4 +6,5 @@ module.exports = {
globals: {
__i18n_text_domain__: 'default',
},
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/effective-module-tree/jest.config.js
Expand Up @@ -4,4 +4,5 @@ module.exports = {
// Node project, no need to transform anything
transformIgnorePatterns: [ '<rootDir>/', '/node_modules/' ],
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/eslint-config-wpcalypso/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/eslint-plugin-wpcalypso/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/format-currency/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
5 changes: 3 additions & 2 deletions packages/format-currency/package.json
Expand Up @@ -4,6 +4,7 @@
"description": "JavaScript library for formatting currency",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"calypso:src": "src/index.js",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -29,8 +30,8 @@
},
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "yarn run clean",
"prepare": "transpile"
"build": "transpile",
"prepack": "yarn run clean && yarn run build"
},
"types": "types"
}
1 change: 1 addition & 0 deletions packages/i18n-calypso-cli/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/i18n-calypso/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
5 changes: 3 additions & 2 deletions packages/i18n-calypso/package.json
Expand Up @@ -4,6 +4,7 @@
"description": "i18n JavaScript library on top of Tannin originally used in Calypso",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"calypso:src": "src/index.js",
"types": "types/index.d.ts",
"sideEffects": false,
"repository": {
Expand Down Expand Up @@ -39,7 +40,7 @@
},
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "yarn run clean",
"prepare": "transpile"
"build": "transpile",
"prepack": "yarn run clean && yarn run build"
}
}
1 change: 1 addition & 0 deletions packages/load-script/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
5 changes: 3 additions & 2 deletions packages/load-script/package.json
Expand Up @@ -4,6 +4,7 @@
"description": "Async Script Loader.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"calypso:src": "src/index.js",
"keywords": [
"wordpress"
],
Expand All @@ -28,7 +29,7 @@
},
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "yarn run clean",
"prepare": "transpile"
"build": "transpile",
"prepack": "yarn run clean && yarn run build"
}
}
1 change: 1 addition & 0 deletions packages/media-library/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/photon/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
5 changes: 3 additions & 2 deletions packages/photon/package.json
Expand Up @@ -4,6 +4,7 @@
"description": "JavaScript library for the WordPress.com Photon image manipulation service",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"calypso:src": "src/index.js",
"sideEffects": false,
"repository": {
"type": "git",
Expand Down Expand Up @@ -38,7 +39,7 @@
},
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "yarn run clean",
"prepare": "transpile"
"build": "transpile",
"prepack": "yarn run clean && yarn run build"
}
}
5 changes: 3 additions & 2 deletions packages/popup-monitor/package.json
Expand Up @@ -4,6 +4,7 @@
"description": "Utility to facilitate the monitoring of a popup window close action.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"calypso:src": "src/index.js",
"sideEffects": false,
"keywords": [
"wordpress",
Expand All @@ -29,8 +30,8 @@
],
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "yarn run clean",
"prepare": "transpile"
"build": "transpile",
"prepack": "yarn run clean && yarn run build"
},
"dependencies": {
"lodash": "^4.17.15"
Expand Down
1 change: 1 addition & 0 deletions packages/request-external-access/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
5 changes: 3 additions & 2 deletions packages/request-external-access/package.json
Expand Up @@ -4,6 +4,7 @@
"description": "Utility for requesting authorization of sharing services.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"calypso:src": "src/index.js",
"sideEffects": false,
"keywords": [
"wordpress",
Expand All @@ -30,8 +31,8 @@
],
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "yarn run clean",
"prepare": "transpile"
"build": "transpile",
"prepack": "yarn run clean && yarn run build"
},
"dependencies": {
"@automattic/popup-monitor": "^1.0.0"
Expand Down
1 change: 1 addition & 0 deletions packages/social-previews/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
5 changes: 3 additions & 2 deletions packages/social-previews/package.json
Expand Up @@ -4,6 +4,7 @@
"description": "A suite of components to generate previews for a post for both social and search engines",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"calypso:src": "src/index.js",
"sideEffects": [
"*.css",
"*.scss"
Expand Down Expand Up @@ -34,8 +35,8 @@
],
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "yarn run clean",
"prepare": "transpile && copy-assets"
"build": "transpile && copy-assets",
"prepack": "yarn run clean && yarn run build"
},
"dependencies": {
"@babel/runtime": "^7.11.1",
Expand Down
1 change: 1 addition & 0 deletions packages/tree-select/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
5 changes: 3 additions & 2 deletions packages/tree-select/package.json
Expand Up @@ -11,6 +11,7 @@
"license": "GPL-2.0-or-later",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"calypso:src": "src/index.js",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -29,7 +30,7 @@
],
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "yarn run clean",
"prepare": "transpile"
"build": "transpile",
"prepack": "yarn run clean && yarn run build"
}
}
1 change: 1 addition & 0 deletions packages/viewport-react/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
5 changes: 3 additions & 2 deletions packages/viewport-react/package.json
Expand Up @@ -4,6 +4,7 @@
"description": "React helpers for tracking viewport changes",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"calypso:src": "src/index.js",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -30,8 +31,8 @@
},
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "yarn run clean",
"prepare": "transpile"
"build": "transpile",
"prepack": "yarn run clean && yarn run build"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 1 addition & 0 deletions packages/viewport/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
5 changes: 3 additions & 2 deletions packages/viewport/package.json
Expand Up @@ -4,6 +4,7 @@
"description": "Vanilla helpers for tracking viewport changes",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"calypso:src": "src/index.js",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -18,8 +19,8 @@
"homepage": "https://github.com/Automattic/wp-calypso/tree/HEAD/packages/viewport#readme",
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "yarn run clean",
"prepare": "transpile"
"build": "transpile",
"prepack": "yarn run clean && yarn run build"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 1 addition & 0 deletions packages/webpack-config-flag-plugin/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: '@automattic/calypso-build',
rootDir: __dirname,
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};
1 change: 1 addition & 0 deletions packages/wp-babel-makepot/jest.config.js
Expand Up @@ -2,4 +2,5 @@ module.exports = {
rootDir: __dirname,
testMatch: [ '<rootDir>/**/test/*.[jt]s?(x)', '!**/.eslintrc.*', '!**/examples/**' ],
cacheDirectory: '<rootDir>/../../.cache/jest',
resolver: '<rootDir>/../../test/module-resolver.js',
};