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

release: 1.2.0 #8

Merged
merged 1 commit into from
Sep 6, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: npm publish
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.2.0 Sept 5, 2022

- [fix: update for >=6.0.43](https://github.com/pixelcollective/laravel-mix-wp-blocks/pull/7) by [@joshuafredrickson](https://github.com/joshuafredrickson)

## 1.1.0 May 24th, 2020

### Added
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ yarn add -D @tinypixelco/laravel-mix-wp-blocks
In webpack.config.js:

```js
require("@tinypixelco/laravel-mix-wp-blocks")
require("@tinypixelco/laravel-mix-wp-blocks");

mix.block('resources/assets/scripts/blocks.js', 'scripts')
mix.block("resources/assets/scripts/blocks.js", "scripts");
```

By doing so you'll find that you can now utilize all `@wordpress` scoped dependencies using ECMAScript 6 import syntax. Example:

```js
import { RichText } from '@wordpress/block-editor'
import { RichText } from "@wordpress/block-editor";
```

These packages are included as [webpack externals](https://webpack.js.org/configuration/externals/), so there is no reason to add them to your package file.
Expand All @@ -39,15 +39,15 @@ You will also find a php manifest file accompanying each script in your distribu
Additional [Dependency Extraction Webpack Plugin options](https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin#options) maybe be provided as a third argument to `mix.block()`:

```js
mix.block('resources/assets/scripts/blocks.js', 'scripts', {
outputFormat: 'json',
})
mix.block("resources/assets/scripts/blocks.js", "scripts", {
outputFormat: "json",
});
```

Besides the plugin options there is a special flag for the common use case of turning off `@babel/runtime/regenerator` handling by `wp-polyfill`.

```js
mix.block('resources/assets/scripts/blocks.js', 'scripts', {
mix.block("resources/assets/scripts/blocks.js", "scripts", {
disableRegenerator: true,
})
```
});
```
52 changes: 27 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const mix = require('laravel-mix')
const JavaScript = require('laravel-mix/src/components/JavaScript')
const DependencyExtractionPlugin = require('@wordpress/dependency-extraction-webpack-plugin')
const mix = require("laravel-mix");
const JavaScript = require("laravel-mix/src/components/JavaScript");
const DependencyExtractionPlugin = require("@wordpress/dependency-extraction-webpack-plugin");

/**
* Laravel Mix WP Block
Expand All @@ -11,12 +11,13 @@ const DependencyExtractionPlugin = require('@wordpress/dependency-extraction-web
class Block extends JavaScript {
constructor() {
super();
this.context = Mix
this.context = Mix;
}

name() {
return ['blocks', 'block']
return ["blocks", "block"];
}

/**
* All dependencies that should be installed by Mix.
*
Expand All @@ -25,12 +26,12 @@ class Block extends JavaScript {
dependencies() {
this.requiresReload = `
Dependencies have been installed. Please run again.
`
`;

return [
'@wordpress/babel-preset-default',
'@wordpress/dependency-extraction-webpack-plugin',
]
"@wordpress/babel-preset-default",
"@wordpress/dependency-extraction-webpack-plugin",
];
}

/**
Expand All @@ -42,18 +43,19 @@ class Block extends JavaScript {
* @return {void}
*/
register(entry, output, options = {}) {
this.pluginOptions = (
options.disableRegenerator === true ? {
...options,
requestToExternal: function(request) {
if (request === '@babel/runtime/regenerator') {
return null
this.pluginOptions =
options.disableRegenerator === true
? {
...options,
requestToExternal: function (request) {
if (request === "@babel/runtime/regenerator") {
return null;
}
},
}
},
} : options
)
: options;

super.register(entry, output)
super.register(entry, output);
}

/**
Expand All @@ -64,7 +66,7 @@ class Block extends JavaScript {
webpackPlugins() {
return new DependencyExtractionPlugin({
...this.pluginOptions,
})
});
}

/**
Expand All @@ -74,10 +76,10 @@ class Block extends JavaScript {
*/
babelConfig() {
return {
presets: ['@wordpress/babel-preset-default'],
}
presets: ["@wordpress/babel-preset-default"],
};
}
}

mix.extend('block', new Block())
mix.extend('blocks', new Block())
mix.extend("block", new Block());
mix.extend("blocks", new Block());
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
{
"name": "@tinypixelco/laravel-mix-wp-blocks",
"version": "1.1.0",
"version": "1.2.0",
"description": "Laravel mix extension to transpile WordPress blocks.",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/pixelcollective/laravel-mix-wp-blocks"
},
"keywords": [
"laravel",
"mix",
"laravel mix",
"wordpress",
"gutenberg",
"react"
"wordpress"
],
"author": "Kelly Mears <[email protected]> (https://kellymears.me)",
"license": "MIT",
"bugs": {
"url": "https://github.com/pixelcollective/laravel-mix-wp-blocks/issues"
},
"homepage": "https://github.com/pixelcollective/laravel-mix-wp-blocks#readme"
}
"homepage": "https://github.com/pixelcollective/laravel-mix-wp-blocks#readme",
"main": "index.js"
}