Skip to content

Commit

Permalink
Changing block.ts to block.json and amending TS config to support
Browse files Browse the repository at this point in the history
  • Loading branch information
joelclimbsthings committed Mar 9, 2023
1 parent e1ccec9 commit 947b3f1
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 29 deletions.
@@ -0,0 +1,23 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "woocommerce/product-name",
"title": "Product name",
"category": "widgets",
"description": "The product name.",
"keywords": [ "products", "name", "title" ],
"textdomain": "default",
"attributes": {
"name": {
"type": "string"
}
},
"supports": {
"align": false,
"html": false,
"multiple": false,
"reusable": false,
"inserter": false,
"lock": false
}
}
Expand Up @@ -31,7 +31,7 @@ export function Edit() {
name={ 'woocommerce-product-name' }
placeholder={ __( 'e.g. 12 oz Coffee Mug', 'woocommerce' ) }
onChange={ setName }
value={ name }
value={ name || '' }
/>
</div>
);
Expand Down
Expand Up @@ -2,7 +2,7 @@
* Internal dependencies
*/
import { initBlock } from '../../utils';
import metadata from './block';
import metadata from './block.json';
import { Edit } from './edit';

const { name } = metadata;
Expand Down
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import { init as initName } from '../name';
import { init as initName } from '../details-name-block';

export const initBlocks = () => {
initName();
Expand Down
23 changes: 0 additions & 23 deletions packages/js/product-editor/src/components/name/block.ts

This file was deleted.

Expand Up @@ -7,7 +7,7 @@ import { BlockInstance, createBlock } from '@wordpress/blocks';
/**
* Internal dependencies
*/
import nameBlock from '../components/name/block';
import nameBlock from '../components/details-name-block/block.json';

export function parseProductToBlocks( product: Partial< Product > ) {
const blocks: BlockInstance[] = [];
Expand Down
7 changes: 6 additions & 1 deletion packages/js/product-editor/tsconfig-cjs.json
@@ -1,6 +1,11 @@
{
"extends": "../tsconfig-cjs",
"include": [
"**/*",
"src/**/*.json"
],
"compilerOptions": {
"outDir": "build"
"outDir": "build",
"resolveJsonModule": true,
}
}
7 changes: 6 additions & 1 deletion packages/js/product-editor/tsconfig.json
@@ -1,10 +1,15 @@
{
"extends": "../tsconfig",
"include": [
"**/*",
"src/**/*.json"
],
"compilerOptions": {
"rootDir": "src",
"outDir": "build-module",
"declaration": true,
"declarationMap": true,
"declarationDir": "./build-types"
"declarationDir": "./build-types",
"resolveJsonModule": true,
}
}

0 comments on commit 947b3f1

Please sign in to comment.