Commit Graph

65 Commits

Author SHA1 Message Date
Vladimir Reznichenko 07a71106dc
Monorepo: actualize loaders paths filtering for better Webpack performance. (#49714) 2024-07-29 15:20:17 +02:00
Vladimir Reznichenko 46f952eeb5
Monorepo: enable babel-loader and Jest caching (inc. CI) (#49656)
In this PR, we are consolidating babel-loader caching and adding Jest caching, improving build/testing times locally and in CI. The improvement comes from cache covering transpile steps in the mentioned processes.
2024-07-19 09:40:01 +02:00
Sam Seay 9fa32b4f2b
Migrate StateInput, CountryInput and custom fields to native `<select>` (#48180) 2024-07-12 21:17:54 +00:00
Vladimir Reznichenko 4311640de2
Monorepo: caching deps per target package in GH actions (#49020)
In this PR, we are implementing per-package build and caching, which optimizes build and fetching cached dependencies times across our workflows.
2024-07-10 14:39:49 +02:00
Sam Seay eaf57e9f15
Create a separate bundle for cart and checkout (#48010) 2024-07-10 21:23:17 +12:00
Sam Seay 2d4295469d
Remove all usage of WOOCOMMERCE_BLOCKS_PHASE and introduce BUNDLE_EXPERIMENTAL_BLOCKS (#47807) 2024-06-05 20:14:16 +12:00
Sam Seay ff102c4921
Add vendor bundling of blocks frontend bundle to improve cart/checkout performance (#45859) 2024-04-04 15:31:02 +13:00
Christopher Allford dc5aa18f35 Wireit Added: `@woocommerce/block-library` 2023-12-09 22:35:11 -08:00
Christopher Allford b4fd0c3b7b Fixed Blocks INI File Path 2023-12-09 21:33:34 -08:00
Christopher Allford 8b6036a30e Changed Blocks Build Output 2023-12-09 18:18:25 -08:00
David Arenas 9e9f0341e2 Interactivity API: implement the new `store()` API (https://github.com/woocommerce/woocommerce-blocks/pull/11071)
* Sync Interactivity API code with Gutenberg

* New store() API

* Store raw actions

* Update wc-interactivity-store implementation

* Replace `wc_store` with `wc_initial_state`

* Parse and populate initial state

* Allow store parts in `store()`

* Accept namespaces in directive paths

* Add $$namespace to directives' object values

* Make namespace parsing more robust

* Use DeepPartial type for store parts

* Do not pass `rawStore` to `afterLoad` callbacks

* Simplify `store()` a bit

* Implement `privateStore()`

* Sync context directive with Gutenberg

* Refactor scope and extract getters per scope

* Add namespace to getters and actions

* Remove current privateStore implementation

* Remove `afterLoad` option from `store`

* Use same proxy handlers for ns, getters and actions

* Set scope inside `evaluate`

* Refactor proxy handlers

* Improve types a bit

* Catch errors in async actions

* Implement stacks for scopes and namespaces

* Implement `getElement`

* Change directives object structure

* Remove unnecessary import

* Implement private stores

* Return value from sync actions

* Minor optimizations and improved comments

* Don't use async inside `data-wp-watch`

* Use a single Provider in context directive

* Remove DeepPartial type

* Do not check if element exists

* Add the `current` prop of state inside the scope

* Move getters outside scope

* Fix wc-key assignment

* Fix missing `navigate` in directives

* Fix namespace not being picked in the same element

* Deep merge raw stores instead of proxied ones

* Fix namespace assignment

* Allow forward slashes in namespaces

* Migration of Product Collection and Product Button blocks to the new `store()` API (https://github.com/woocommerce/woocommerce-blocks/pull/11558)

* Refactor Product Button with new store() API

* Use `wc_initial_state` in Product Button

* Fix namespace

* Remove unnecessary state

* Test namespaces in directive paths

* Add test context with namespace

* Simplify woo-test context

* Move addToCart and animations to a file

* Do not pass `rawStore` to `afterLoad` callbacks

* Move callbacks and actions back to the main file

Because the animation was broken.

* Remove selectors in favor of state

* Use default ns in `getContext` for state and actions

* Remove `afterLoad` callback

* Remove unnecessary ns

* Fix getContext in add-to-cart

* Replace namespace and delete unnecessary store

* Pass context types only once

* Use an alternative for requestIdleCallback

* Add previous react code for notices

* Add namespace to Product Collection block

* Replace getTextButton with getButtonText

* Add block name to the ProductCollection namespace

* fix style HTML code

* Remove circular deps error on the Interactivity API

* Product Gallery block: Migrate to new Interactivity API store (https://github.com/woocommerce/woocommerce-blocks/pull/11721)

* Migrate Product Gallery block to new Interactivity API store

* Fix some references

* Add missing data-wc-interactive

* Fix an additional namespace

* Remove unnecessary click handler

* Dialog working

* Refactor action names

* Reindex PHP array

There was some missing indexes, which turned the array into an object in JS.

* Remove unused event handlers

* Move next/previous logic to external function

* Move StorePart util to the types folder

* Rename namespace to `woocommerce/product-gallery`

* Undo product collection namespace renaming

* Remove unnecessary namespace

* Don't hide the large image on page load

* Minor refactorings

* Fix eslint error

* Fix php cs errors with spacing and double arrows alignment

* Disable no-use-before-define rule for eslint

* Disable @typescript-eslint/ban-types rule for eslint

* Fix parsed context error in e2e tests

* Fix context parser for Thumbnail image

* Move store to the top of the frontend file

* Add interactivity api utils to the @woocommerce/utils alias

* Replace deprecated event attribute

---------

Co-authored-by: Luis Herranz <luisherranz@gmail.com>
Co-authored-by: David Arenas <david.arenas@automattic.com>
Co-authored-by: roykho <roykho77@gmail.com>

---------

Co-authored-by: David Arenas <david.arenas@automattic.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: roykho <roykho77@gmail.com>

* Fix error when closing product gallery dialog with keyboard escape key

* use wc_initial_state instead of wc_store

---------

Co-authored-by: Luis Herranz <luisherranz@gmail.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: roykho <roykho77@gmail.com>
2023-11-21 11:46:15 +01:00
Alexandre Lara 3ecd34e01a Upgrade webpack to version 5 (https://github.com/woocommerce/woocommerce-blocks/pull/8013)
* Upgrade terser-webpack-plugin to version 4.2.3

* Upgrade webpack-bundle-analyzer to 4.7.0

* Upgrade to Webpack version 5

* Upgrade @wordpress/dependency-extraction-webpack-plugin to 4.6.0

* Upgrade dependency copy-webpack-plugin to version 11.0.0

* Upgrade dependency terser-webpack-plugin to version 5.3.6

* Replace webpack-rtl-plugin with the new @automattic/webpack-rtl-plugin

* Replace module.issuer with the new ModuleGraph API

There is a warning appearing in the console when running the application. This is due to the fact that the module.issuer has been deprecated on Webpack 5 and replaced with the new ModuleGraph API. This commit replaces the deprecated API with the new one.

* Upgrade babel and babel plugins to latest version

* Replace jsonpFunction with the new uniqueName property

Add a unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. It defaults to output.library name or the package name from package.json in the context, if both aren't found, it is set to an ''.

* Replace cacheDirectory inline configuration with options.cacheDirectory

* Upgrade @wordpress/e2e-tests dependency to version 5.6.0

* Remove babel-plugin-transform-react-jsx dependency

Remove babel-plugin-transform-react-jsx dependency because it is already included in @wordpress/babel-preset-default

* Remove unnecessary Babel dependencies

Remove some unnecessary babel dependencies that are already included in the @babel/preset-env package.

* Upgrade puppeteer dependency to version 16.2.0

* Remove caret from package.json dependencies

* Fix Storybook build error

This commit fixes the Storybook build error that was being caused because of Storybook by default uses Webpack 4, but since we are currently upgrading our webpack to version 5, we need to install some required dependencies and also explicitly tell Storybook to use Webpack 5.

* Fix package-lock.json after merging with trunk

* Add own webpack-rtl-plugin implementation to the project

Before upgrading Webpack to version 5, we were using the original `webpack-rtl-plugin` released by Romain Berger; unfortunately, this plugin is not compatible with Webpack 5, so we replaced it with `@automattic/webpack-rtl-plugin`. The problem is that `@automattic/webpack-rtl-plugin` by default generates files with the '.rtl.css' suffix and does not provide a way to change that.

This commit adds our own implementation of the `webpack-rtl-plugin` (adapted from `@automattic/webpack-rtl-plugin`) that is compatible with Webpack 5 and allows us to change the suffix of the generated files to follow the recommended way defined by Wordpress (https://codex.wordpress.org/Right-to-Left_Language_Support)

* Change conditional clause to be multiline

* Fix package-lock.json after merge with trunk

* Fix package-lock.json after merge with trunk

* Rename files to fix ESLint errors

This commit renames files that have the .js extension but contain JSX code. This is causing ESLint to throw errors because by default our Eslint configuration expects only files with the .jsx extension to contain JSX code.

* Fix package-lock.json file

* Add is-plain-obj module to the transformIgnorePatterns of jest config

* Update package-lock.json

* Fix package-lock.json

* Upgrade @wordpress/i18n dependency to version 4.31.0

* Update package-lock.json

* Update composer lock file

* Fix Webpack config for Webpack 5

* Add the package-lock.json

* Remove unsupported config from webpack

* Fix error with Webpack build

* Add wait for network idle to the tests

* Attempt to fix e2e test

* Restore promise.all

* Upgrade puppeteer to v17.1.3

* Upgrade expect-puppeteer

* Update expect-puppeteer

* Downgrade expect-puppeteer

* Revert "Upgrade puppeteer to v17.1.3"

This reverts commit 61ed52a56f131961f3970b6fb22cdd8b540bada3.

* Upgrade Puppeteer to version 17.1.3

* Fix executionContext.frame is not a function error

* Fix e2e tests

* Remove isExperimentalBuild from Product Gallery inner blocks

* Upgrade Webpack and Webpack-cli to latest version

* Upgrade postcss and mini-css plugins

* Fix error with mini-cart block

* Fix styling error with filter blocks

* Fix issue when running unit tests

* Fix storybook script not loading

* Fix a11y issue in Storybook

* Fix error when multiple isExperimentalBuild was being used

* Prevent error when layout is not present in the attributes object

* Update `chunkIds` to `named` in Webpack

* Add cache groups to the Webpack configs
2023-09-20 17:31:52 -03:00
Tung Du 0cfea936e4 Fix: load blocks style separately for classic themes (https://github.com/woocommerce/woocommerce-blocks/pull/10758)
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2023-09-08 11:15:48 +07:00
Luigi Teschio 97474e4040 Create wc-all-block-styles chunk with all the styles for classic themes (https://github.com/woocommerce/woocommerce-blocks/pull/10543) 2023-08-11 14:12:34 +02:00
Patricia Hillebrandt 3ec684818e Fix: WooCommerce Blocks causing malfunction of the navigation block on WordPress 6.3 (https://github.com/woocommerce/woocommerce-blocks/pull/10388)
* Make sure the revert button is registered and enqueued for usage exclusively in the site editor.

* Register and enqueue the styles for the revert button.

* Rename the files.

* Revert "Rename the file renames."

This reverts commit c0330ce70fec20bea1f957eddcf458881e16242c.

* Add plugin-proposal-optional-chaining to the WebPack plugins config.

* Rename the files.

* Remove unnecessary dependencies as those are already provided via : more specifically, get_script_data.

* Address CR.
2023-07-31 07:03:10 +00:00
Mike Jolley 025a280b33 Babel and Autoprefixer updates (https://github.com/woocommerce/woocommerce-blocks/pull/10341) 2023-07-26 10:58:17 +01:00
Albert Juhé Lluveras df3ff6793e Per block stylesheets (https://github.com/woocommerce/woocommerce-blocks/pull/9831)
* Clean up blank lines

* Update Webpack config

* Update PHP logic to load block styles

* Style fixes

* Style fixes (II)

* Style fixes (III)

* Style fixes (IV)

* Fix missing stylesheets in the Site Editor

* Fix wrong return values in some PHP method docs

* Fix missing ProductPrice stylesheet causing 404 in tests

* Fix missing ProductGallery stylesheet causing 404 in tests
2023-07-04 13:06:48 +02:00
David Arenas 5a3f6e2e2e Update the Interactivity API files to include latest changes (https://github.com/woocommerce/woocommerce-blocks/pull/9924)
* Update Interactivity API JS files

* Disable TS checks in the Interactivity API for now

* Add new SSR files

* Replace wp_ prefixes with wc_ ones

* Replace wp- prefix with wc-

* Replace guternberg_ prefix with woocommerce_

* Remove file comments from Gutenberg

* Rename files with `wp` prefix

* Fix code to load Interactivity API php files

* Remove TODO comments

* Replace @wordpress with @woocommerce

* Update Webpack configuration

* Fix directive prefix

* Remove interactivity folder from tsconfig exclude

* Add client-side navigation meta tag code

* Remove unneeded blocks.php file

* Fix store tag id

* Register Interactivity API runtime script

* Fix Interactivity API runtime registering

* Remove all files related to directive processing in PHP

* Move json_encode to Store's render method
2023-06-27 12:22:12 +02:00
Mike Jolley 2d506f9f57 Fix/you do not need lodash (https://github.com/woocommerce/woocommerce-blocks/pull/9161)
* Remove lodash `without` usage

* isNumber

* Remove lodash `difference`

* Replace lodash isEmpty with type guard

* Replace isObject with type guard

* remove lodash noop

* Replace lodash clamp

* replace lodash uniqueId

* Remove uniqueId import

* Add eslint rule to restrict lodash import

* Replace lodash range

* Replace lodash has() function

Replace lodash has

* replace omitby

* Replace lodash isEqual with fastDeepEqual

* Replace kebabCase with change-case package

* Replace lodash camelCase

Replace lodash mapKeys with function

Move mapkeys to utility

Create camelCaseKeys which replaces usage of mapKeys

* Replace lodash debounce with custom utiity

* replace lodash keyby

* Replace lodash pick with native function

* Replace lodash cloneDeep with klona

* Replace snake case keys package with change case

* Replace sortBy with fast sort package

* replace isEmpty with type guard

* Replace pickBy usage in validation reducer

* Replace groupBy usage in search list control

* Replace flatten, uniqBy usage in getProducts()

* Remove setWith and clone from updateState

* Replace custom useThrottle with useThrottledCallback from use-debounce package

* onSelectRate can use-debounce

* Fix missing flatten

* Update assets/js/data/cart/test/push-changes.ts

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-04-28 11:29:45 +01:00
David Arenas 2ee332d4d4 Update directives prefix to `data-woo-` (https://github.com/woocommerce/woocommerce-blocks/pull/8316)
* Update Interactivity API

* Change `wp` prefixes to `woo`

* Use `woo` prefix for the directives runtime bundle
2023-02-20 17:48:33 +01:00
David Arenas d2c5c4a9c3 Add the Interactivity API runtime to WooCommerce blocks (https://github.com/woocommerce/woocommerce-blocks/pull/8220)
* Add Interactivity API scripts

* Enqueue scripts if Products exists for testing

* Test client-side transitions

* Remove script enqueue

* Remove hpq dependency

* Update Interactivity scripts to latest version

* Remove interactivity scripts from core entries

* Create webpack config for interactivity api

A plugin for optional chaining is required as the repo uses Webpack 4 for now.

* Enqueue the directives runtime

* Updated wp directives code

* Use a filter to enque the directives runtime

* Remove base-interactivity alias for now

* Add path for modules inside base-interactivity

* Revert "Remove base-interactivity alias for now"

This reverts commit 7c6cbee372c65e430590d98c1819b6b4b0a97d93.

* Remove unnecessary filter and enqueue

* Update router code

* Update Interactivity location and alias

* Use hook `init` for script registering

Co-authored-by: Mario Santos <santosguillamot@gmail.com>
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
2023-01-26 12:39:25 +01:00
Mike Jolley c49426570d React Based Local Pickup Settings Screen (https://github.com/woocommerce/woocommerce-blocks/pull/7581)
* Move payment methods

* Setup entrypoints

* Sortable implementation

* Sortable

* Basic UI in place for settings

* Hydrate real settings

* Form updates values

* Styling and save button placement

* useSettings hook

* Prepare for save

* delete

* Add location button

* Remove className

* Conditional display of taxes

* Save via API

* Update general settings to designs

* Modal styles

* Style table

* Border colors and radius

* Added e2e tests

* use node 16

* Enqueue states in admin

* Use render from wordpress/element

* Missing handle style

* Enable translations

* Remove curried function

* Todo for inline settings

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2023-01-12 15:40:15 +01:00
kmanijak 00ac537474 Make each Bundle Analyzer report open in new tab with the proper title (https://github.com/woocommerce/woocommerce-blocks/pull/8045)
* Make each Bundle Analzyer report open in new tab with the proper title
2022-12-29 17:00:30 +01:00
Mike Jolley fdbe4e7c54 Remove legacy handling on the PHP side (https://github.com/woocommerce/woocommerce-blocks/pull/7978) 2022-12-22 17:04:54 +01:00
Thomas Roberts 6f85ab593f Use backslashes to fix webpack build on windows (https://github.com/woocommerce/woocommerce-blocks/pull/6798)
* Use backslashes to fix webpack build on windows

* Update regex to use square brackets, and update copywebpack path for Windows

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-11-02 03:24:19 -07:00
Saad Tarhi 085242bbe9 Clean the top-level of the /build folder (https://github.com/woocommerce/woocommerce-blocks/pull/7047)
* Generate Inner Blocks' JSON files in a common folder

* Get the correct metadata path for the Inner Blocks

The Inner Blocks' metadata lives now in the `/build/inner-blocks`. But,
the function `get_block_metadata_path` was only looking for metadata
inside the top-level of the `build/` folder
2022-09-26 15:02:36 +01:00
Luigi Teschio ffbf5823d3 Product Query Block POC (Phase 1) (https://github.com/woocommerce/woocommerce-blocks/pull/6812)
* Move `EditorBlock` to general `type-defs`

`EditorBlock` was scoped under the `featured-items` directory at the time of its creation. It is, however, a useful type that should be shared repo-wide. For this reason, I am moving it into the `blocks` type-defs and updating all the references.

* Define types for the Product Query block

Also defines a more generic `WooCommerceBlockVariation` type which should be also useful in the future to implement a similar pattern.

* Add Product Query utils

Add two utility functions:

 1. `isWooQueryBlockVariation`: is used to check whether a given block is a variation of the core Query Loop block, and also one of the allowed variations within our repo. See: `QueryVariation` enum type.
2. `setCustomQueryAttribute`: is a shorthand to set an attribute within the variation query attribute.

* Refactor and cleanup the JS demo code

Specifically:

1. Creates a `constant.ts` file to store all shared constants. Currently, the default variation attributes.
2. Move the variations to their own directory. One file per variation.
3. Move the inspector controls into own file and create a conditional logic to allow showing only certain settings.

* Update webpack config

* Add ProductQuery class

* Fix `QueryVariation` enum

We had changed the Products on Sale variation slug to something else,
but we had forgotten to update the proper enum.

* Remove unused params from `update_query`

The filter we added to Gutenberg will pass the block and the page,
as we might need them in the future and we want to minimize the
amount of changes we'll have to do upstream.

However, we currently do not use those, so I removed
them from our own inner function.

Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-08-18 10:02:21 +02:00
Saad Tarhi dc97e5af1e Fix missing translations in inspector (https://github.com/woocommerce/woocommerce-blocks/pull/6737)
* Try registering the "cart taxes" inner block

Registering server side. This example isn't working, but I'm pushing to
share it and see what's wrong with this implementation.

* Fix registering the cart taxes inner block issue

* Update translation script loading

* Remove unnecessary JS translation

The translation should work fine by getting the title & description from
the `block.json` file

* Put back the initial code in the 'Cart Taxes' inner block

We didn't provide the correct `block.json` file path server side,
that's why the `metadata` wasn't correctly registered

* Generate `block.json`files for inner blocks

This is the first step on fixing the missing translations of `metadata`
in `block.json` files

* Set the folder name exactly the same as the inner block name

We are doing this first test for the `Cart taxes` inner block.

The `Block` & its containing folder need to have the same name for:
- Consistency
- We use the `Block` name to get the file Path

* Update imports after folder renaming

* Get block name directly from the JSON metadata

Getting the block name from the JSON metadata is less error prone than
extracting it from the file path.

And no need to rename all our `inner-blocks` to get the correct
`block.json` path

* Revert folder naming change of `Cart taxes` inner block

Since we are getting the `block` name directly from the `block.json`
metadata instead of extracting it from the file path, there is no need
to keep their names in sync anymore

* Fix missing translations for the `Cart Subtotal` Block

* Register only the client-side settings on the client

When the block is registered on the server, you only need to register
the client-side settings on the client using the same block’s name.
See [docs](https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#javascript-client-side).

* Add schema validation to `block.json`

Development is improved by using a defined schema definition file.
Supported editors can provide help like tooltips, autocomplete, and
schema validation.

* Use the same `editor_script` as the parent block

This prevents WordPress from generating script tags to inexistant
inner blocks JS files

* Add C&C inner blocks in Cart.php & Checkout.php

This is a refactoring to keep the block types controller file less
overloaded

* Fix all Cart inner blocks missing translations

* Create the "AbstractInnerBlock" class

The "Inner Blocks" will use their parent's script, so no need to create
new scripts for each one of them

And, our "Inner Blocks" should always be registered using the metadata file

* Update the "Inner Blocks" PHP classes

* Fix PHP lint erros & update function description

* Fix missing translations bug for all Checkout Inner Blocks

* Update src/BlockTypes/Checkout.php

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* skip lazy loaded scripts

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-08-01 15:57:33 +01:00
Michael P. Pfeiffer 521f93619b Upgrade wp-prettier to 2.6.2 and reformat the codebase (https://github.com/woocommerce/woocommerce-blocks/pull/6566)
* Remove mixed tabs and spaces in tsconfig.json

* Update formatting in json files

* Upgrade wp-prettier to 2.6.2
2022-06-15 11:56:52 +02:00
Tung Du 45f48e6b0a Fix: Register Filter Blocks using `block.json` (https://github.com/woocommerce/woocommerce-blocks/pull/6505) 2022-06-09 21:45:24 +07:00
Seghir Nadir d3c2f638fa Revert changes to webpack build output (https://github.com/woocommerce/woocommerce-blocks/pull/6456)
* revert changes to webpack file

* fix loading of chunks

* revert changes to assets api as well

* include chunks from other blocks

* bail early if there is no build folder
2022-05-25 16:59:51 +01:00
Seghir Nadir 238ab01ab2 Refactor webpack splitting to fix missing translation (https://github.com/woocommerce/woocommerce-blocks/pull/6420)
* don't splitChunk frontend scripts

* simplfy output folders

* reduce minimum chunk size to 10kb

* add all inner blocks for loading

* better splitChunks

* update translation code

* wait for scripts

* try sleeping

* fix loading translation

* fix tests for mini cart

* simplfy po logic

* automate loading chunks

* rename webpack group file

* rename block.json path
2022-05-23 15:58:13 +01:00
Alba Rincón d61c5116ad Start using `block.json` for the `Products by Attribute` block (https://github.com/woocommerce/woocommerce-blocks/pull/6414) 2022-05-23 10:10:06 +02:00
Alba Rincón 6e5ebdff85 Start using the `block.json` metadata file for `Products by Tag` (https://github.com/woocommerce/woocommerce-blocks/pull/6403)
* Start using the block.json metadata file for `Products by Tag`

* Remove comment

* Add version, schema, and text domain

* Add defaults

* Remove wrong keyword

* Add tag icon when registering the block
2022-05-20 14:43:43 +02:00
Lucio Giannotta 7fcc561db1 Refactor Featured Category and Featured Product blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6406)
This PR creates a new directory called `featured-items` which includes both blocks.
All the shared code lives at the top level of that directory.

Individual blocks still have their own directories, with their `block.json` and all other relevant configuration.

All the functionalities have been refactored out into their own files, accepting configuration when relevant, but mostly de-duplicating all the code.

Styles have also been refactored using mixins and extends and they mostly live in one place.
2022-05-19 18:16:46 +02:00
Alba Rincón 42166068b6 Start using the `block.json` metadata file for `Handpicked products` (https://github.com/woocommerce/woocommerce-blocks/pull/6392)
* Start using the `block.json` metadata file for `Handpicked products`

* Add the `properties` attribute to properly parse booleans

* Remove comment

* Add schema, delete version
2022-05-13 14:57:34 +02:00
Alba Rincón bdfd1da4c5 Start using the `block.json` metadata file for the `Featured Category` block (https://github.com/woocommerce/woocommerce-blocks/pull/6300)
* Start using the `block.json` metadata file for the `Featured Category` block

* Get default attributes from the `block.json` file

* Remove unnecessary `get_block_metadata_defaults` function

* Add alt attribute to the block.json file

* Remove unused imports
2022-04-28 17:31:59 +02:00
Alba Rincón 0aac2c59ef Start using the `block.json` metadata file for the `Featured Product` block (https://github.com/woocommerce/woocommerce-blocks/pull/6296)
* Start using the `block.json` metadata file for the `Feature Product` block

* Get default attributes from the block.json file

* Add removed comment

* Remove unnecessary `get_block_metadata_defaults` function

* Add alt default to block.json
2022-04-28 17:04:56 +02:00
Tomasz Tunik f7f1b89dc5 Upgrade @wordpress/scripts and /env packages (https://github.com/woocommerce/woocommerce-blocks/pull/6114)
* upgrade wordpress/scripts to 22.3

* update jest config/setup

* add explicit-exports-references plugin

to handle payment-method-config.tsx spying on external methods
the way code is output now changed and tests like this would not
work anymore as transpilet files were no longer using exports but
local references to methods.

* missing snapshot

* make cart-products E2E test more stable

* surppress eslint error in test file

* fix css stylelint issues

* update eslint-plugin-woocommerce eslint package

* remove temp test:e2e:start script

* re-run

* add stylelint as recommended extension

* remove redundant types (provided by packages now)

* patch update @testing-library/jest-dom
2022-03-28 15:00:20 +02:00
Mike Jolley 67283c02be Compare assets from builds (https://github.com/woocommerce/woocommerce-blocks/pull/5634)
* Comparison workflow

* Update locks
2022-02-02 14:56:16 +00:00
Thomas Roberts 5e32fb0576 Add `CopyWebpackPlugin` to ensure `block.json` is copied to `build` (https://github.com/woocommerce/woocommerce-blocks/pull/5692)
* Add CopyWebpackPlugin and add block metadata to build

* Check build directory for block.json
2022-02-01 16:42:15 +00:00
Mike Jolley 1f6f97d860 Implement `@wordpress/scripts` analyze script (https://github.com/woocommerce/woocommerce-blocks/pull/5589)
* Add analyze-bundles command, replacing explore

* Replace source map explorer from webpack in favour of BundleAnalyzerPlugin

* Update deps

* update locks
2022-01-28 11:40:23 +00:00
Mike Jolley cfeb5558b7 Update WordPress Monorepo packages with React 17x support (https://github.com/woocommerce/woocommerce-blocks/pull/5223)
* Use npm 14

* Update WP packages

* Update non-dev wordpress dependencies

* Remove usage of @automattic/data-stores

* Moves tag, search-list-control components back into private `editor-components` to mitigate dependency conflicts with`@woocommerce/components`

* Fix tests with act()

* package-lock

* fix broken maps

* Patch 14x package

* update locks

* Revert nvmrc change

* Fix tests due to debounce

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2021-12-07 15:47:50 +00:00
Mike Jolley ed0a9a2d91 Implement `@wordpress/babel-preset-default` (drops IE11 support) (https://github.com/woocommerce/woocommerce-blocks/pull/5212)
* Implement @wordpress/babel-preset-default

* remove alraedy included libs

* remove other deps

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2021-11-23 14:49:35 +00:00
Mike Jolley 25e5ea7b51 Define chunkFilename with contenthash in lazy loaded assets (https://github.com/woocommerce/woocommerce-blocks/pull/5094)
* Define chunkFilename with contenthash

* Fix editor filename
2021-11-09 15:10:47 +00:00
Niels Lange 9428e791c9 Replace deprecated divisions with math.div($size, $base) (https://github.com/woocommerce/woocommerce-blocks/pull/4550)
* Replace deprecated SASS divisions

* Load '@use "sass:math"' before any other rules
2021-08-24 13:37:43 +02:00
Mike Jolley b941b0c332 Update Dependencies to Latest Versions supporting React 16x (https://github.com/woocommerce/woocommerce-blocks/pull/4532)
* Update storybook to 6.3.6

* @storybook/addon-knobs

* Remove need for wordpress-compose imports

This functionality exists in WP 5.5 so we don't need to import the package any more.

* Update to latest non 17x packages

* Composer update

* Fix for @babel/plugin-proposal-nullish-coalescing-operator and spinner style

* onSelect was called before init

* Add back env

* Update locks

* Revert browserlist config increase (ie11 support dropped needs separate discussion)

* update locks

* SVG can come from the external

* Import from components package where possible (5.5 has Gutenberg 9.2.0) and revert component package version change

* Revert component imports. Import from wordpress-components in the frontend context. This removes `wp-components`  dependency from all -frontend asset files.
2021-08-05 10:26:00 +01:00
Seghir Nadir 2f440bbe20 Move SlotFillProvider to frontend only (https://github.com/woocommerce/woocommerce-blocks/pull/4437)
* Move SlotFillProvider to frontend only

* remove extra config for editor scripts

* update tests
2021-07-08 16:04:13 +01:00
Mike Jolley 33c55353f7 Add Terser to preserve translator comments (https://github.com/woocommerce/woocommerce-blocks/pull/4379)
* Tidy and document current configs

* Add terser package

* sharedConfig with Terser plugin setup

* replace todo

* revert change to alias

* Package lock update

* ci to install

* Revert "ci to install"

This reverts commit a65b7f3ca8ef8ab1cb78f825a43ca8df07f784bb.

* revert shared config

* fix extra comma

* tweak setup

* Missing jsx
2021-06-29 12:18:29 +01:00
Mike Jolley 44b2003ec5 Document and update naming of Block Asset Handles (https://github.com/woocommerce/woocommerce-blocks/pull/4324)
* Document the rules

* Document rules inline

* Typescript support in webpack

* Update webpack config

* Update existing handles

* Name stylesheets same as handles

* prefix vendors and blocks

* Fix script filename
2021-06-09 15:09:42 +01:00