Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Add alias to blocks dir for imports.
Browse files Browse the repository at this point in the history
Allows us to use exports from the blocks dir as "external" imports. This
way we do not need to write long, relative import paths (which can be
fragile in the long run).
  • Loading branch information
danielwrobert committed Oct 31, 2022
1 parent fc6abee commit 72e87b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assets/js/atomic/blocks/product-elements/rating/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { __ } from '@wordpress/i18n';
import { useBlockProps } from '@wordpress/block-editor';
import { BlockEditProps } from '@wordpress/blocks';
import { useEffect } from 'react';
import { ProductQueryContext as Context } from '@woocommerce/blocks/product-query/types';

/**
* Internal dependencies
Expand All @@ -13,7 +14,6 @@ import Block from './block';
import withProductSelector from '../shared/with-product-selector';
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
import { Attributes } from './types';
import { ProductQueryContext as Context } from '../../../../blocks/product-query/types';

const Edit = ( {
attributes,
Expand Down
4 changes: 4 additions & 0 deletions bin/webpack-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ const getAlias = ( options = {} ) => {
__dirname,
`../assets/js/${ pathPart }base/utils/`
),
'@woocommerce/blocks': path.resolve(
__dirname,
`../assets/js/${ pathPart }/blocks`
),
'@woocommerce/editor-components': path.resolve(
__dirname,
`../assets/js/${ pathPart }editor-components/`
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@woocommerce/base-hocs/*": [ "assets/js/base/hocs/*" ],
"@woocommerce/base-hooks": [ "assets/js/base/hooks" ],
"@woocommerce/base-utils": [ "assets/js/base/utils" ],
"@woocommerce/blocks/*": [ "assets/js/blocks/*" ],
"@woocommerce/editor-components/*": [
"assets/js/editor-components/*"
],
Expand Down

0 comments on commit 72e87b3

Please sign in to comment.