@wordpress/build 0.4.1-next.8fd3f8831.0 → 0.5.1-next.79a2f3cdd.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cache/tsconfig.tsbuildinfo +1 -1
- package/LICENSE.md +1 -1
- package/build-module/build.mjs +1454 -0
- package/build-module/build.mjs.map +7 -0
- package/build-module/dependency-graph.mjs +149 -0
- package/build-module/dependency-graph.mjs.map +7 -0
- package/build-module/package-utils.mjs +44 -0
- package/build-module/package-utils.mjs.map +7 -0
- package/build-module/php-generator.mjs +48 -0
- package/build-module/php-generator.mjs.map +7 -0
- package/build-module/route-utils.mjs +85 -0
- package/build-module/route-utils.mjs.map +7 -0
- package/build-module/wordpress-externals-plugin.mjs +257 -0
- package/build-module/wordpress-externals-plugin.mjs.map +7 -0
- package/package.json +3 -3
- package/src/build.mjs +44 -41
- package/src/php-generator.mjs +2 -8
- package/templates/constants.php.template +14 -0
- package/templates/index.php.template +0 -6
- package/templates/module-registration.php.template +3 -1
- package/templates/page-wp-admin.php.template +4 -1
- package/templates/page.php.template +12 -3
- package/templates/routes-registration.php.template +4 -2
- package/templates/script-registration.php.template +4 -2
- package/templates/style-registration.php.template +6 -2
- package/templates/version.php.template +0 -11
|
@@ -28,6 +28,8 @@ foreach ( $routes as $route ) {
|
|
|
28
28
|
// Helper function to register routes for a page
|
|
29
29
|
$register_routes_callback = function ( $page_routes, $page_slug_underscore, $register_function_name ) {
|
|
30
30
|
return function () use ( $page_routes, $page_slug_underscore, $register_function_name ) {
|
|
31
|
+
// Load build constants
|
|
32
|
+
$build_constants = require __DIR__ . '/constants.php';
|
|
31
33
|
foreach ( $page_routes as $route ) {
|
|
32
34
|
$content_handle = null;
|
|
33
35
|
$route_handle = null;
|
|
@@ -41,7 +43,7 @@ $register_routes_callback = function ( $page_routes, $page_slug_underscore, $reg
|
|
|
41
43
|
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
|
|
42
44
|
wp_register_script_module(
|
|
43
45
|
$content_handle,
|
|
44
|
-
|
|
46
|
+
$build_constants['build_url'] . 'routes/' . $route['name'] . '/content' . $extension,
|
|
45
47
|
$content_asset['module_dependencies'] ?? array(),
|
|
46
48
|
$content_asset['version'] ?? false
|
|
47
49
|
);
|
|
@@ -57,7 +59,7 @@ $register_routes_callback = function ( $page_routes, $page_slug_underscore, $reg
|
|
|
57
59
|
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
|
|
58
60
|
wp_register_script_module(
|
|
59
61
|
$route_handle,
|
|
60
|
-
|
|
62
|
+
$build_constants['build_url'] . 'routes/' . $route['name'] . '/route' . $extension,
|
|
61
63
|
$route_asset['module_dependencies'] ?? array(),
|
|
62
64
|
$route_asset['version'] ?? false
|
|
63
65
|
);
|
|
@@ -53,7 +53,9 @@ if ( ! function_exists( '{{PREFIX}}_register_package_scripts' ) ) {
|
|
|
53
53
|
* Register all package scripts.
|
|
54
54
|
*/
|
|
55
55
|
function {{PREFIX}}_register_package_scripts( $scripts ) {
|
|
56
|
-
|
|
56
|
+
// Load build constants
|
|
57
|
+
$build_constants = require __DIR__ . '/constants.php';
|
|
58
|
+
$default_version = ! SCRIPT_DEBUG ? $build_constants['version'] : time();
|
|
57
59
|
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
|
|
58
60
|
|
|
59
61
|
$scripts_dir = __DIR__ . '/scripts';
|
|
@@ -75,7 +77,7 @@ if ( ! function_exists( '{{PREFIX}}_register_package_scripts' ) ) {
|
|
|
75
77
|
{{PREFIX}}_override_script(
|
|
76
78
|
$scripts,
|
|
77
79
|
$script_data['handle'],
|
|
78
|
-
|
|
80
|
+
$build_constants['build_url'] . 'scripts/' . $script_data['path'] . $extension,
|
|
79
81
|
$dependencies,
|
|
80
82
|
$version,
|
|
81
83
|
true
|
|
@@ -43,7 +43,10 @@ if ( ! function_exists( '{{PREFIX}}_register_package_styles' ) ) {
|
|
|
43
43
|
* @param WP_Styles $styles WP_Styles instance.
|
|
44
44
|
*/
|
|
45
45
|
function {{PREFIX}}_register_package_styles( $styles ) {
|
|
46
|
-
|
|
46
|
+
// Load build constants
|
|
47
|
+
$build_constants = require __DIR__ . '/constants.php';
|
|
48
|
+
$default_version = ! SCRIPT_DEBUG ? $build_constants['version'] : time();
|
|
49
|
+
$suffix = SCRIPT_DEBUG ? '' : '.min';
|
|
47
50
|
|
|
48
51
|
$styles_dir = __DIR__ . '/styles';
|
|
49
52
|
$styles_file = $styles_dir . '/index.php';
|
|
@@ -59,13 +62,14 @@ if ( ! function_exists( '{{PREFIX}}_register_package_styles' ) ) {
|
|
|
59
62
|
{{PREFIX}}_override_style(
|
|
60
63
|
$styles,
|
|
61
64
|
$style_data['handle'],
|
|
62
|
-
|
|
65
|
+
$build_constants['build_url'] . 'styles/' . $style_data['path'] . $suffix . '.css',
|
|
63
66
|
$style_data['dependencies'],
|
|
64
67
|
$default_version
|
|
65
68
|
);
|
|
66
69
|
|
|
67
70
|
// Enable RTL support (WordPress automatically loads -rtl.css variant)
|
|
68
71
|
$styles->add_data( $style_data['handle'], 'rtl', 'replace' );
|
|
72
|
+
$styles->add_data( $style_data['handle'], 'suffix', $suffix );
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
|