@salesforce/pwa-kit-dev 3.8.0-preview.0-basepath → 3.8.0-preview.2-basepath

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/configs/babel/babel-config.js +33 -0
  2. package/configs/eslint/README.md +21 -0
  3. package/configs/eslint/eslint-config.js +11 -0
  4. package/configs/eslint/index.js +11 -0
  5. package/configs/eslint/no-react.js +18 -0
  6. package/configs/eslint/partials/base.js +38 -0
  7. package/configs/eslint/partials/jest.js +24 -0
  8. package/configs/eslint/partials/react.js +29 -0
  9. package/configs/eslint/partials/typescript-permit-any.js +31 -0
  10. package/configs/eslint/partials/typescript.js +17 -0
  11. package/configs/eslint/recommended.js +20 -0
  12. package/configs/eslint/safe-types.js +20 -0
  13. package/configs/jest/jest-babel-transform.js +19 -0
  14. package/configs/jest/jest.config.js +40 -0
  15. package/configs/jest/mocks/fileMock.js +9 -0
  16. package/configs/jest/mocks/styleMock.js +9 -0
  17. package/configs/jest/mocks/svgMock.js +11 -0
  18. package/configs/webpack/config-names.js +19 -0
  19. package/configs/webpack/config.js +406 -0
  20. package/configs/webpack/overrides-plugin.js +168 -0
  21. package/configs/webpack/overrides-plugin.test.js +388 -0
  22. package/configs/webpack/plugins.js +86 -0
  23. package/configs/webpack/test/overrides/exists.js +7 -0
  24. package/configs/webpack/test/overrides/newExtension.js +7 -0
  25. package/configs/webpack/test/overrides/path/data.js +7 -0
  26. package/configs/webpack/test/overrides/path/index.js +7 -0
  27. package/configs/webpack/test/overrides/path/index.mock.js +7 -0
  28. package/configs/webpack/test/overrides/path/nested/icon.svg +0 -0
  29. package/configs/webpack/test/package.json +13 -0
  30. package/configs/webpack/utils.js +23 -0
  31. package/package.json +5 -4
  32. package/ssr/server/build-dev-server.js +468 -0
  33. package/ssr/server/build-dev-server.test.js +661 -0
  34. package/ssr/server/loading-screen/css/main.css +272 -0
  35. package/ssr/server/loading-screen/css/normalize.css +349 -0
  36. package/ssr/server/loading-screen/img/cloud-1.svg +1 -0
  37. package/ssr/server/loading-screen/img/cloud-2.svg +1 -0
  38. package/ssr/server/loading-screen/img/cloud-3.svg +1 -0
  39. package/ssr/server/loading-screen/img/cloud.svg +1 -0
  40. package/ssr/server/loading-screen/img/codey-arm.svg +1 -0
  41. package/ssr/server/loading-screen/img/codey-bear.svg +1 -0
  42. package/ssr/server/loading-screen/img/codey-bg.svg +1 -0
  43. package/ssr/server/loading-screen/img/codey-cloud.svg +1 -0
  44. package/ssr/server/loading-screen/img/codey-search.svg +1 -0
  45. package/ssr/server/loading-screen/img/codey.svg +1 -0
  46. package/ssr/server/loading-screen/img/codeyCarry.svg +1 -0
  47. package/ssr/server/loading-screen/img/devDocumentation.svg +1 -0
  48. package/ssr/server/loading-screen/img/devGithub.svg +1 -0
  49. package/ssr/server/loading-screen/img/devTrailhead.svg +1 -0
  50. package/ssr/server/loading-screen/img/logo.svg +1 -0
  51. package/ssr/server/loading-screen/img/slds_spinner_brand_9EA9F1.gif +0 -0
  52. package/ssr/server/loading-screen/index.html +129 -0
  53. package/ssr/server/test_fixtures/app/main.js +6 -0
  54. package/ssr/server/test_fixtures/app/static/favicon.ico +0 -0
  55. package/ssr/server/test_fixtures/localhost.pem +45 -0
  56. package/utils/mocks/dependency-tree-mock-data.js +127 -0
  57. package/utils/script-utils.js +497 -0
  58. package/utils/script-utils.test.js +496 -0
  59. package/utils/test-fixtures/minimal-built-app/ssr.js +9 -0
  60. package/utils/test-fixtures/minimal-built-app/static/favicon.ico +0 -0
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*
8
+ * Copyright (c) 2021, salesforce.com, inc.
9
+ * All rights reserved.
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
12
+ */
13
+ const config = {
14
+ sourceType: 'unambiguous',
15
+ presets: [[require('@babel/preset-env'), {
16
+ targets: {
17
+ node: 18
18
+ }
19
+ }], require('@babel/preset-typescript'), require('@babel/preset-react')],
20
+ plugins: [require('@babel/plugin-transform-async-to-generator'), require('@babel/plugin-proposal-object-rest-spread'), require('@babel/plugin-transform-object-assign'), [require('@babel/plugin-transform-runtime'), {
21
+ regenerator: true
22
+ }], require('@babel/plugin-syntax-dynamic-import'), require('@loadable/babel-plugin'), require('@babel/plugin-proposal-optional-chaining'), [require('babel-plugin-formatjs'), {
23
+ idInterpolationPattern: '[sha512:contenthash:base64:6]',
24
+ ast: true
25
+ }], require('@babel/plugin-transform-async-generator-functions')],
26
+ env: {
27
+ test: {
28
+ presets: [require('@babel/preset-env'), require('@babel/preset-react')],
29
+ plugins: [require('babel-plugin-dynamic-import-node-babel-7')]
30
+ }
31
+ }
32
+ };
33
+ var _default = exports.default = config;
@@ -0,0 +1,21 @@
1
+ # `pwa-kit-dev` ESLint configuations
2
+
3
+ ## Configs
4
+
5
+ There are three configurations available:
6
+
7
+ * `recommended`: The default expectation for PWA Kit projects. Provides rules for JavaScript, TypeScript, React, and Jest.
8
+ * `no-react`: The `recommended` configuration with React rules removed to avoid logging unnecessary warnings.
9
+ * `safe-types`: The `recommended` configuration with stricter rules in TypeScript files regarding usage of the `any` type.
10
+
11
+ ## Usage
12
+
13
+ Extending a `pwa-kit-dev` ESLint configuration is a little bit from the standard way to extend a file. Because the config is not from a package with a name starting with `eslint-config-`, you must provide the full path to the configuration file using `require.resolve()`. For example, a configuration file that simply extends the `recommended` configuration would look like this:
14
+
15
+ ```js
16
+ module.exports = {
17
+ extends: [require.resolve('@salesforce/pwa-kit-dev/configs/eslint/recommended')]
18
+ }
19
+ ```
20
+
21
+ > **Note:** For convenience, `@salesforce/pwa-kit-dev/configs/eslint` is provided as an alias for the `recommended` configuration.
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2023, Salesforce, Inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+
10
+ /** This is an alias of the default/recommended config, provided for backwards compatibility with v2. */
11
+ module.exports = require('./index');
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2023, Salesforce, Inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+
10
+ // Default config is an alias for 'recommended'
11
+ module.exports = require('./recommended');
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2023, Salesforce, Inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+
10
+ /**
11
+ * Recommended configuration for PWA Kit projects that don't use React.
12
+ * Contains rules for JavaScript, TypeScript, and Jest.
13
+ */
14
+ module.exports = {
15
+ extends: [require.resolve('./partials/base')],
16
+ // TypeScript and Jest rules only apply to specific file paths, so they are overrides.
17
+ overrides: [require('./partials/typescript-permit-any'), require('./partials/jest')]
18
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2023, Salesforce, Inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+
10
+ /** Base configuration used by all PWA Kit packages. */
11
+ module.exports = {
12
+ parser: '@typescript-eslint/parser',
13
+ parserOptions: {
14
+ ecmaVersion: 2017,
15
+ sourceType: 'module',
16
+ ecmaFeatures: {
17
+ jsx: true
18
+ }
19
+ },
20
+ env: {
21
+ es6: true,
22
+ node: true,
23
+ browser: true
24
+ },
25
+ extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
26
+ plugins: ['@typescript-eslint', 'prettier'],
27
+ reportUnusedDisableDirectives: true,
28
+ rules: {
29
+ // The goal of the no-empty-function rule is to minimize the contextual knowledge required
30
+ // by the reader. The suggested fix for empty functions is to add comments indicating that
31
+ // the empty function is intentional. However, in my opinion, it is clear from context that
32
+ // most of our empty arrow functions are intentional no-ops, so we don't want the rule to be
33
+ // enforced for those.
34
+ '@typescript-eslint/no-empty-function': ['error', {
35
+ allow: ['arrowFunctions']
36
+ }]
37
+ }
38
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2023, Salesforce, Inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+
10
+ /** Override configuration for Jest files. */
11
+ module.exports = {
12
+ // Jest (v29) default test match pattern
13
+ files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
14
+ plugins: ['jest'],
15
+ extends: ['plugin:jest/recommended', 'plugin:jest/style'],
16
+ rules: {
17
+ 'jest/expect-expect': ['warn', {
18
+ // Anything starting with `expect` counts as an assertion
19
+ assertFunctionNames: ['expect*', '**.expect*']
20
+ }],
21
+ // This doesn't reliably report errors :(
22
+ 'jest/no-standalone-expect': ['off']
23
+ }
24
+ };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2023, Salesforce, Inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+
10
+ /** Extension of the base configuration for use in React projects. */
11
+ module.exports = {
12
+ parserOptions: {
13
+ ecmaFeatures: {
14
+ jsx: true
15
+ }
16
+ },
17
+ extends: ['plugin:react/recommended', 'plugin:jsx-a11y/recommended'],
18
+ plugins: ['jsx-a11y', 'react', 'react-hooks', 'use-effect-no-deps'],
19
+ settings: {
20
+ react: {
21
+ version: 'detect'
22
+ }
23
+ },
24
+ rules: {
25
+ 'react-hooks/rules-of-hooks': 'error',
26
+ // react-hooks/exhaustive-deps has too many false positives; use-effect-no-deps is nicer
27
+ 'use-effect-no-deps/use-effect-no-deps': 'warn'
28
+ }
29
+ };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
7
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ /*
9
+ * Copyright (c) 2023, Salesforce, Inc.
10
+ * All rights reserved.
11
+ * SPDX-License-Identifier: BSD-3-Clause
12
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
13
+ */
14
+
15
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
16
+ const base = require('./typescript');
17
+
18
+ /**
19
+ * Override configuration for TypeScript files. Adds rules that require type checking, but allows
20
+ * the use of implicit or explicit `any`.
21
+ */
22
+ module.exports = _objectSpread(_objectSpread({}, base), {}, {
23
+ rules: _objectSpread(_objectSpread({}, base.rules), {}, {
24
+ '@typescript-eslint/no-explicit-any': 'off',
25
+ '@typescript-eslint/no-unsafe-argument': 'off',
26
+ '@typescript-eslint/no-unsafe-assignment': 'off',
27
+ '@typescript-eslint/no-unsafe-call': 'off',
28
+ '@typescript-eslint/no-unsafe-member-access': 'off',
29
+ '@typescript-eslint/no-unsafe-return': 'off'
30
+ })
31
+ });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2023, Salesforce, Inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+
10
+ /** Override configuration for TypeScript files. Adds rules that require type checking. */
11
+ module.exports = {
12
+ files: ['**/*.ts', '**/*.tsx'],
13
+ extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking'],
14
+ parserOptions: {
15
+ project: true
16
+ }
17
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2023, Salesforce, Inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+
10
+ /**
11
+ * Recommended configuration for PWA Kit projects.
12
+ * Contains rules for JavaScript, TypeScript, React, and Jest.
13
+ */
14
+ module.exports = {
15
+ extends: [require.resolve('./partials/base'),
16
+ // React rules live in `extends`, rather than `overrides`, because any file can have React code.
17
+ require.resolve('./partials/react')],
18
+ // TypeScript and Jest rules only apply to specific file paths, so they are overrides.
19
+ overrides: [require('./partials/typescript-permit-any'), require('./partials/jest')]
20
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2023, Salesforce, Inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+
10
+ /**
11
+ * Configuration for PWA Kit projects. Extends the recommended configuration with stricter rules
12
+ * that restrict usage of the `any` type.
13
+ */
14
+ module.exports = {
15
+ extends: [require.resolve('./partials/base'),
16
+ // React rules live in `extends`, rather than `overrides`, because any file can have React code.
17
+ require.resolve('./partials/react')],
18
+ // TypeScript and Jest rules only apply to specific file paths, so they are overrides.
19
+ overrides: [require('./partials/typescript'), require('./partials/jest')]
20
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2021, salesforce.com, inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+
10
+ // Allows us to use a single babel config at the root to be shared across
11
+ // packages. See: https://babeljs.io/docs/en/config-files#jest
12
+
13
+ /* eslint-env node */
14
+
15
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
16
+ const babelJest = require('babel-jest');
17
+ module.exports = babelJest.createTransformer({
18
+ rootMode: 'upward'
19
+ });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _path = _interopRequireDefault(require("path"));
4
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
5
+ /*
6
+ * Copyright (c) 2021, salesforce.com, inc.
7
+ * All rights reserved.
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
10
+ */
11
+
12
+ module.exports = {
13
+ testURL: 'http://localhost/',
14
+ verbose: true,
15
+ collectCoverage: true,
16
+ // We need access to jsdom globally in tests.
17
+ // jsdom isn't accessible so we need to use this
18
+ // 3rd party test environment wrapper. When we
19
+ // upgrade to jest 28, we can revert back to jsdom.
20
+ testEnvironment: 'jest-environment-jsdom-global',
21
+ testPathIgnorePatterns: ['node_modules', 'build'],
22
+ moduleNameMapper: {
23
+ '\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': _path.default.join(__dirname, 'mocks', 'fileMock.js'),
24
+ '\\.(svg)$': _path.default.join(__dirname, 'mocks', 'svgMock.js'),
25
+ '\\.(css|less)$': _path.default.join(__dirname, 'mocks', 'styleMock.js')
26
+ },
27
+ globals: {
28
+ DEBUG: true,
29
+ NODE_ENV: 'test',
30
+ Progressive: {
31
+ // BuildOrigin can be any non-empty string. It does not have to be /mobify/xyz
32
+ // This is used by tests that call getAssetUrl in pwa-kit-react-sdk to simulate
33
+ // asset urls.
34
+ buildOrigin: '/mobify/bundle/development/'
35
+ }
36
+ },
37
+ transform: {
38
+ '^.+\\.(js|jsx|ts|tsx)$': _path.default.join(__dirname, 'jest-babel-transform.js')
39
+ }
40
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2021, salesforce.com, inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+ module.exports = 'test-file-stub';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2021, salesforce.com, inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+ module.exports = {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2021, salesforce.com, inc.
5
+ * All rights reserved.
6
+ * SPDX-License-Identifier: BSD-3-Clause
7
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+ module.exports = {
10
+ viewBox: '0 0 24 24'
11
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SSR = exports.SERVER = exports.REQUEST_PROCESSOR = exports.CLIENT_OPTIONAL = exports.CLIENT = void 0;
7
+ /*
8
+ * Copyright (c) 2022, salesforce.com, inc.
9
+ * All rights reserved.
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
12
+ */
13
+
14
+ // Must be named "client" and "server". See - https://www.npmjs.com/package/webpack-hot-server-middleware#usage
15
+ const CLIENT = exports.CLIENT = 'client';
16
+ const SERVER = exports.SERVER = 'server';
17
+ const CLIENT_OPTIONAL = exports.CLIENT_OPTIONAL = 'client-optional';
18
+ const SSR = exports.SSR = 'ssr';
19
+ const REQUEST_PROCESSOR = exports.REQUEST_PROCESSOR = 'request-processor';