Skip to content

Commit 4e6b7df

Browse files
committed
feat: save external dependencies as json instead of php
Our enqueue library can handle json just fine.
1 parent 7c88193 commit 4e6b7df

File tree

4 files changed

+4
-13
lines changed

4 files changed

+4
-13
lines changed

packages/scripts/@types/json2php/index.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/scripts/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"find-up": "^5.0.0",
5757
"gradient-string": "^1.2.0",
5858
"handlebars": "^4.7.7",
59-
"json2php": "^0.0.4",
6059
"less-loader": "7.3.0",
6160
"lockfile": "^1.0.4",
6261
"log-symbols": "^4.0.0",

packages/scripts/src/plugins/DependencyExtractionWebpackPlugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-disable no-restricted-syntax */
22
import webpack, { Compiler } from 'webpack';
3-
import json2php from 'json2php';
43
import path from 'path';
54
import fs from 'fs';
65

@@ -86,7 +85,7 @@ export class DependencyExtractionWebpackPlugin {
8685
}
8786

8887
stringify(asset: any) {
89-
return `<?php return ${json2php(JSON.parse(JSON.stringify(asset)))};`;
88+
return JSON.stringify(asset, null, 2);
9089
}
9190

9291
/**
@@ -144,7 +143,9 @@ export class DependencyExtractionWebpackPlugin {
144143

145144
const assetString = this.stringify(assetData);
146145

147-
const fileName = `${entrypointName.split('?', 2)[0]}.dependencies.wp.php`;
146+
const fileName = `${
147+
entrypointName.split('?', 2)[0]
148+
}.dependencies.wp.json`;
148149
const outputPath = path.resolve(
149150
this.compiler.outputPath,
150151
this.options.appDir,

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7961,11 +7961,6 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1:
79617961
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
79627962
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=
79637963

7964-
json2php@^0.0.4:
7965-
version "0.0.4"
7966-
resolved "https://registry.yarnpkg.com/json2php/-/json2php-0.0.4.tgz#6bd85a1dda6a5dd7e91022bb24403cc1b7c2ee34"
7967-
integrity sha1-a9haHdpqXdfpECK7JEA8wbfC7jQ=
7968-
79697964
json5@^1.0.1:
79707965
version "1.0.1"
79717966
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe"

0 commit comments

Comments
 (0)