@wordpress/build 0.26.0 → 0.28.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.
@@ -4,6 +4,12 @@ import { createHash } from 'crypto';
4
4
  import { camelCase } from 'change-case';
5
5
  import { getPackageInfo } from './package-utils.mjs';
6
6
 
7
+ /**
8
+ * Prefix of the ids of the modules that expose a script's global to an ES
9
+ * module build.
10
+ */
11
+ const GLOBAL_MODULE_PREFIX = '\0wp-global:';
12
+
7
13
  /**
8
14
  * Generate a content hash from file contents.
9
15
  * Uses SHA256 algorithm for broad compatibility across Node.js versions.
@@ -35,7 +41,7 @@ async function generateContentHash(
35
41
  }
36
42
 
37
43
  /**
38
- * Create WordPress externals plugin for esbuild.
44
+ * Create WordPress externals plugin for Rolldown.
39
45
  * This plugin handles WordPress package externals and vendor libraries,
40
46
  * treating them as external dependencies available via global variables.
41
47
  *
@@ -43,7 +49,7 @@ async function generateContentHash(
43
49
  * @param {string|false} scriptGlobal Global variable name (e.g., 'wp', 'myPlugin') or false to disable globals.
44
50
  * @param {Object} externalNamespaces Additional namespaces to externalize (e.g., { 'woo': { global: 'woo', handlePrefix: 'woocommerce' } }).
45
51
  * @param {string} handlePrefix Handle prefix for main package (e.g., 'wp', 'mp'). Defaults to packageNamespace.
46
- * @return {Function} Function that creates the esbuild plugin instance.
52
+ * @return {Function} Function that creates the Rolldown plugin instance.
47
53
  */
48
54
  export function createWordpressExternalsPlugin(
49
55
  packageNamespace,
@@ -52,13 +58,18 @@ export function createWordpressExternalsPlugin(
52
58
  handlePrefix
53
59
  ) {
54
60
  /**
55
- * WordPress externals plugin for esbuild.
61
+ * WordPress externals plugin for Rolldown.
62
+ *
63
+ * Scripts are read from their globals: in a classic script (`iife`) build,
64
+ * as external modules passed to the bundle's function, and in an ES module
65
+ * (`esm`) build, through a module exporting the global. Script modules stay
66
+ * external imports, resolved by the import map.
56
67
  *
57
68
  * @param {string} assetName Base name for the asset file (e.g., 'index.min').
58
69
  * @param {string} buildFormat Build format: 'iife' for classic scripts, 'esm' for modules.
59
70
  * @param {Array<string>} extraDependencies Additional dependencies to include in the asset file.
60
71
  * @param {boolean} generateAssetFile Whether to generate the .asset.php file. Default true.
61
- * @return {Object} esbuild plugin object.
72
+ * @return {import('rolldown').Plugin} Rolldown plugin object.
62
73
  */
63
74
  return function wordpressExternalsPlugin(
64
75
  assetName = 'index.min',
@@ -66,338 +77,346 @@ export function createWordpressExternalsPlugin(
66
77
  extraDependencies = [],
67
78
  generateAssetFile = true
68
79
  ) {
69
- return {
70
- name: 'wordpress-externals',
71
- /** @param {import('esbuild').PluginBuild} build */
72
- setup( build ) {
73
- const dependencies = new Set();
74
- const moduleDependencies = new Map();
75
-
76
- /**
77
- * Check if a package import is a script module.
78
- * A package is considered a script module if it has wpScriptModuleExports
79
- * and the specific import path (root or subpath) is declared in wpScriptModuleExports.
80
- *
81
- * @param {import('./package-utils.mjs').PackageJson} packageJson Package.json object.
82
- * @param {string|null} subpath Subpath after package name, or null for root import.
83
- * @return {boolean} True if the import is a script module.
84
- */
85
- function isScriptModuleImport( packageJson, subpath ) {
86
- const { wpScriptModuleExports } = packageJson;
87
-
88
- if ( ! wpScriptModuleExports ) {
89
- return false;
90
- }
80
+ const dependencies = new Set();
81
+ const moduleDependencies = new Map();
82
+
83
+ /**
84
+ * Check if a package import is a script module.
85
+ * A package is considered a script module if it has wpScriptModuleExports
86
+ * and the specific import path (root or subpath) is declared in wpScriptModuleExports.
87
+ *
88
+ * @param {import('./package-utils.mjs').PackageJson} packageJson Package.json object.
89
+ * @param {string|null} subpath Subpath after package name, or null for root import.
90
+ * @return {boolean} True if the import is a script module.
91
+ */
92
+ function isScriptModuleImport( packageJson, subpath ) {
93
+ const { wpScriptModuleExports } = packageJson;
94
+
95
+ if ( ! wpScriptModuleExports ) {
96
+ return false;
97
+ }
98
+
99
+ // Root import: @wordpress/package-name
100
+ if ( ! subpath ) {
101
+ if ( typeof wpScriptModuleExports === 'string' ) {
102
+ return true;
103
+ }
104
+ if (
105
+ typeof wpScriptModuleExports === 'object' &&
106
+ wpScriptModuleExports[ '.' ]
107
+ ) {
108
+ return true;
109
+ }
110
+ return false;
111
+ }
112
+
113
+ // Subpath import: @wordpress/package-name/subpath
114
+ if (
115
+ typeof wpScriptModuleExports === 'object' &&
116
+ wpScriptModuleExports[ `./${ subpath }` ]
117
+ ) {
118
+ return true;
119
+ }
120
+
121
+ return false;
122
+ }
123
+
124
+ // Map of vendor packages to their global variables and handles
125
+ /** @type {Record<string, {global: string, handle: string}>} */
126
+ const vendorExternals = {
127
+ react: { global: 'React', handle: 'react' },
128
+ 'react-dom': { global: 'ReactDOM', handle: 'react-dom' },
129
+ 'react-dom/client': {
130
+ global: 'ReactDOM',
131
+ handle: 'react-dom',
132
+ },
133
+ 'react/jsx-runtime': {
134
+ global: 'ReactJSXRuntime',
135
+ handle: 'react-jsx-runtime',
136
+ },
137
+ 'react/jsx-dev-runtime': {
138
+ global: 'ReactJSXRuntime',
139
+ handle: 'react-jsx-runtime',
140
+ },
141
+ moment: { global: 'moment', handle: 'moment' },
142
+ lodash: { global: 'lodash', handle: 'lodash' },
143
+ 'lodash-es': { global: 'lodash', handle: 'lodash' },
144
+ jquery: { global: 'jQuery', handle: 'jquery' },
145
+ };
91
146
 
92
- // Root import: @wordpress/package-name
93
- if ( ! subpath ) {
94
- if ( typeof wpScriptModuleExports === 'string' ) {
95
- return true;
96
- }
97
- if (
98
- typeof wpScriptModuleExports === 'object' &&
99
- wpScriptModuleExports[ '.' ]
100
- ) {
101
- return true;
102
- }
103
- return false;
104
- }
147
+ // Build list of package namespace configurations
148
+ const packageExternals = [
149
+ {
150
+ namespace: 'wordpress',
151
+ pattern: /^@wordpress\//,
152
+ globalName: 'wp',
153
+ handlePrefix: 'wp',
154
+ },
155
+ ];
156
+
157
+ // Add custom namespace if different from wordpress and scriptGlobal is not false
158
+ if (
159
+ packageNamespace &&
160
+ packageNamespace !== 'wordpress' &&
161
+ scriptGlobal !== false
162
+ ) {
163
+ packageExternals.push( {
164
+ namespace: packageNamespace,
165
+ pattern: new RegExp( `^@${ packageNamespace }/` ),
166
+ globalName: scriptGlobal,
167
+ handlePrefix: handlePrefix || packageNamespace,
168
+ } );
169
+ }
170
+
171
+ // Add additional external namespaces from configuration
172
+ for ( const [ namespace, config ] of Object.entries(
173
+ externalNamespaces
174
+ ) ) {
175
+ packageExternals.push( {
176
+ namespace,
177
+ pattern: new RegExp( `^@${ namespace }/` ),
178
+ globalName: config.global,
179
+ handlePrefix: config.handlePrefix || namespace,
180
+ } );
181
+ }
182
+
183
+ /**
184
+ * Get the expression of the global exposing a script.
185
+ *
186
+ * @param {string} specifier The script's import specifier, e.g. `@wordpress/blocks` or `react`.
187
+ * @return {string|undefined} The expression, e.g. `window.wp.blocks`, or undefined for a specifier that is not a script.
188
+ */
189
+ function getScriptGlobal( specifier ) {
190
+ if (
191
+ Object.prototype.hasOwnProperty.call(
192
+ vendorExternals,
193
+ specifier
194
+ )
195
+ ) {
196
+ return `window.${ vendorExternals[ specifier ].global }`;
197
+ }
198
+ const externalConfig = packageExternals.find( ( { pattern } ) =>
199
+ pattern.test( specifier )
200
+ );
201
+ if ( ! externalConfig ) {
202
+ return undefined;
203
+ }
204
+ // Extract package name after '@namespace/' prefix
205
+ // e.g., '@wordpress/blocks' or '@my-plugin/data'
206
+ const packagePath = specifier.split( '/' ).slice( 1 ).join( '/' );
207
+ const camelCasedName = camelCase( packagePath );
208
+ return `window.${ externalConfig.globalName }.${ camelCasedName }`;
209
+ }
210
+
211
+ /**
212
+ * Resolve an import of a script to its global.
213
+ *
214
+ * @param {string} specifier The script's import specifier.
215
+ * @param {string} kind The kind of import, e.g. `import-statement` or `require-call`.
216
+ * @return {import('rolldown').ResolveIdResult} The resolved module.
217
+ */
218
+ function resolveScript( specifier, kind ) {
219
+ // The output keeps `require()` calls of external modules as they are,
220
+ // even in a classic script.
221
+ if ( buildFormat === 'iife' && kind !== 'require-call' ) {
222
+ return { id: specifier, external: true };
223
+ }
224
+ return GLOBAL_MODULE_PREFIX + specifier;
225
+ }
105
226
 
106
- // Subpath import: @wordpress/package-name/subpath
107
- if (
108
- typeof wpScriptModuleExports === 'object' &&
109
- wpScriptModuleExports[ `./${ subpath }` ]
110
- ) {
111
- return true;
112
- }
227
+ return {
228
+ name: 'wordpress-externals',
113
229
 
114
- return false;
230
+ outputOptions( options ) {
231
+ if ( buildFormat !== 'iife' ) {
232
+ return null;
115
233
  }
116
-
117
- // Map of vendor packages to their global variables and handles
118
- const vendorExternals = {
119
- react: { global: 'React', handle: 'react' },
120
- 'react-dom': { global: 'ReactDOM', handle: 'react-dom' },
121
- 'react-dom/client': {
122
- global: 'ReactDOM',
123
- handle: 'react-dom',
124
- },
125
- 'react/jsx-runtime': {
126
- global: 'ReactJSXRuntime',
127
- handle: 'react-jsx-runtime',
128
- },
129
- 'react/jsx-dev-runtime': {
130
- global: 'ReactJSXRuntime',
131
- handle: 'react-jsx-runtime',
132
- },
133
- moment: { global: 'moment', handle: 'moment' },
134
- lodash: { global: 'lodash', handle: 'lodash' },
135
- 'lodash-es': { global: 'lodash', handle: 'lodash' },
136
- jquery: { global: 'jQuery', handle: 'jquery' },
234
+ return {
235
+ ...options,
236
+ globals: ( id ) => getScriptGlobal( id ) ?? id,
137
237
  };
238
+ },
138
239
 
139
- // Build list of package namespace configurations
140
- const packageExternals = [
141
- {
142
- namespace: 'wordpress',
143
- pattern: /^@wordpress\//,
144
- globalName: 'wp',
145
- handlePrefix: 'wp',
146
- },
147
- ];
240
+ resolveId( source, importer, extraOptions ) {
241
+ if ( extraOptions.isEntry ) {
242
+ return null;
243
+ }
148
244
 
149
- // Add custom namespace if different from wordpress and scriptGlobal is not false
150
245
  if (
151
- packageNamespace &&
152
- packageNamespace !== 'wordpress' &&
153
- scriptGlobal !== false
246
+ Object.prototype.hasOwnProperty.call(
247
+ vendorExternals,
248
+ source
249
+ )
154
250
  ) {
155
- packageExternals.push( {
156
- namespace: packageNamespace,
157
- pattern: new RegExp( `^@${ packageNamespace }/` ),
158
- globalName: scriptGlobal,
159
- handlePrefix: handlePrefix || packageNamespace,
160
- } );
251
+ dependencies.add( vendorExternals[ source ].handle );
252
+
253
+ return resolveScript( source, extraOptions.kind );
161
254
  }
162
255
 
163
- // Add additional external namespaces from configuration
164
- for ( const [ namespace, config ] of Object.entries(
165
- externalNamespaces
166
- ) ) {
167
- packageExternals.push( {
168
- namespace,
169
- pattern: new RegExp( `^@${ namespace }/` ),
170
- globalName: config.global,
171
- handlePrefix: config.handlePrefix || namespace,
172
- } );
256
+ // Handle package namespace externals (wordpress and custom)
257
+ const externalConfig = packageExternals.find( ( { pattern } ) =>
258
+ pattern.test( source )
259
+ );
260
+ if ( ! externalConfig ) {
261
+ return null;
173
262
  }
174
263
 
175
- for ( const [ packageName, config ] of Object.entries(
176
- vendorExternals
177
- ) ) {
178
- build.onResolve(
179
- {
180
- filter: new RegExp( `^${ packageName }$` ),
181
- },
182
- /** @param {import('esbuild').OnResolveArgs} args */
183
- ( args ) => {
184
- dependencies.add( config.handle );
185
-
186
- return {
187
- path: args.path,
188
- namespace: 'vendor-external',
189
- pluginData: { global: config.global },
190
- };
191
- }
264
+ // Extract package name and subpath from import
265
+ // e.g., '@wordpress/blocks/sub/path' → packageName='@wordpress/blocks', subpath='sub/path'
266
+ const parts = source.split( '/' );
267
+ let packageName = source;
268
+ let subpath = null;
269
+ if ( parts.length > 2 ) {
270
+ packageName = parts.slice( 0, 2 ).join( '/' );
271
+ subpath = parts.slice( 2 ).join( '/' );
272
+ }
273
+ const shortName = parts[ 1 ];
274
+ const handle = `${ externalConfig.handlePrefix }-${ shortName }`;
275
+
276
+ const packageJson = getPackageInfo(
277
+ packageName,
278
+ importer && ! importer.startsWith( '\0' )
279
+ ? path.dirname( importer )
280
+ : null
281
+ );
282
+
283
+ if ( ! packageJson ) {
284
+ return null;
285
+ }
286
+
287
+ let isScriptModule = isScriptModuleImport(
288
+ packageJson,
289
+ subpath
290
+ );
291
+ let isScript = !! packageJson.wpScript;
292
+ if ( isScriptModule && isScript ) {
293
+ // If the package is both a script and a script module, rely on the format being built
294
+ isScript = buildFormat === 'iife';
295
+ isScriptModule = buildFormat === 'esm';
296
+ }
297
+
298
+ const kind =
299
+ extraOptions.kind === 'dynamic-import'
300
+ ? 'dynamic'
301
+ : 'static';
302
+
303
+ if ( isScriptModule ) {
304
+ if ( kind === 'static' ) {
305
+ moduleDependencies.set( source, 'static' );
306
+ } else if ( ! moduleDependencies.has( source ) ) {
307
+ moduleDependencies.set( source, 'dynamic' );
308
+ }
309
+
310
+ return {
311
+ id: source,
312
+ external: true,
313
+ moduleSideEffects: !! packageJson.sideEffects,
314
+ };
315
+ }
316
+
317
+ if ( isScript ) {
318
+ dependencies.add( handle );
319
+
320
+ return resolveScript( source, extraOptions.kind );
321
+ }
322
+
323
+ return null;
324
+ },
325
+
326
+ load: {
327
+ filter: { id: /^\0wp-global:/ },
328
+ handler( id ) {
329
+ const specifier = id.slice( GLOBAL_MODULE_PREFIX.length );
330
+
331
+ return {
332
+ code: `module.exports = ${ getScriptGlobal(
333
+ specifier
334
+ ) };`,
335
+ moduleType: 'js',
336
+ };
337
+ },
338
+ },
339
+
340
+ async writeBundle( outputOptions ) {
341
+ // Format module dependencies as array of arrays with 'id' and 'import' keys
342
+ const moduleDependenciesArray = Array.from(
343
+ moduleDependencies.entries()
344
+ )
345
+ .sort( ( [ a ], [ b ] ) => a.localeCompare( b ) )
346
+ .map(
347
+ ( [ dep, kind ] ) =>
348
+ `array('id' => '${ dep }', 'import' => '${ kind }')`
192
349
  );
350
+
351
+ const moduleDependenciesString =
352
+ moduleDependenciesArray.length > 0
353
+ ? moduleDependenciesArray.join( ', ' )
354
+ : '';
355
+
356
+ // Only generate asset file if requested
357
+ if ( ! generateAssetFile ) {
358
+ return;
193
359
  }
194
360
 
195
- // Handle package namespace externals (wordpress and custom)
196
- for ( const externalConfig of packageExternals ) {
197
- build.onResolve(
198
- { filter: externalConfig.pattern },
199
- /** @param {import('esbuild').OnResolveArgs} args */
200
- ( args ) => {
201
- // Extract package name and subpath from import
202
- // e.g., '@wordpress/blocks/sub/path' → packageName='@wordpress/blocks', subpath='sub/path'
203
- const parts = args.path.split( '/' );
204
- let packageName = args.path;
205
- let subpath = null;
206
- if ( parts.length > 2 ) {
207
- packageName = parts.slice( 0, 2 ).join( '/' );
208
- subpath = parts.slice( 2 ).join( '/' );
209
- }
210
- const shortName = parts[ 1 ];
211
- const handle = `${ externalConfig.handlePrefix }-${ shortName }`;
212
-
213
- const packageJson = getPackageInfo(
214
- packageName,
215
- args.resolveDir
216
- );
217
-
218
- if ( ! packageJson ) {
219
- return undefined;
220
- }
221
-
222
- let isScriptModule = isScriptModuleImport(
223
- packageJson,
224
- subpath
225
- );
226
- let isScript = !! packageJson.wpScript;
227
- if ( isScriptModule && isScript ) {
228
- // If the package is both a script and a script module, rely on the format being built
229
- isScript = buildFormat === 'iife';
230
- isScriptModule = buildFormat === 'esm';
231
- }
232
-
233
- const kind =
234
- args.kind === 'dynamic-import'
235
- ? 'dynamic'
236
- : 'static';
237
-
238
- if ( isScriptModule ) {
239
- if ( kind === 'static' ) {
240
- moduleDependencies.set(
241
- args.path,
242
- 'static'
243
- );
244
- } else if (
245
- ! moduleDependencies.has( args.path )
246
- ) {
247
- moduleDependencies.set(
248
- args.path,
249
- 'dynamic'
250
- );
251
- }
252
-
253
- return {
254
- path: args.path,
255
- external: true,
256
- sideEffects: !! packageJson.sideEffects,
257
- };
258
- }
259
-
260
- if ( isScript ) {
261
- dependencies.add( handle );
262
-
263
- return {
264
- path: args.path,
265
- namespace: 'package-external',
266
- pluginData: {
267
- globalName: externalConfig.globalName,
268
- },
269
- };
270
- }
271
-
272
- return undefined;
273
- }
361
+ // Merge discovered dependencies with extra dependencies
362
+ const allDependencies = new Set( [
363
+ ...dependencies,
364
+ ...extraDependencies,
365
+ ] );
366
+
367
+ const dependenciesString = Array.from( allDependencies )
368
+ .sort()
369
+ .map( ( dep ) => `'${ dep }'` )
370
+ .join( ', ' );
371
+
372
+ // Determine output file path from build config
373
+ let outputFilePath;
374
+ if ( outputOptions.file ) {
375
+ outputFilePath = outputOptions.file;
376
+ } else if ( outputOptions.dir ) {
377
+ // Construct expected output filename from assetName
378
+ // e.g., assetName='index.min' -> 'index.min.js'
379
+ outputFilePath = path.join(
380
+ outputOptions.dir,
381
+ `${ assetName }.js`
274
382
  );
275
383
  }
276
384
 
277
- build.onLoad(
278
- { filter: /.*/, namespace: 'vendor-external' },
279
- /** @param {import('esbuild').OnLoadArgs} args */
280
- ( args ) => {
281
- const global = args.pluginData.global;
385
+ // Collect files to hash
386
+ const filesToHash = [];
387
+ if ( outputFilePath ) {
388
+ filesToHash.push( outputFilePath );
389
+ }
282
390
 
283
- return {
284
- contents: `module.exports = window.${ global };`,
285
- loader: 'js',
286
- };
287
- }
288
- );
391
+ // Generate content-based version hash
392
+ const version = await generateContentHash( filesToHash );
289
393
 
290
- build.onLoad(
291
- { filter: /.*/, namespace: 'package-external' },
292
- /** @param {import('esbuild').OnLoadArgs} args */
293
- ( args ) => {
294
- const globalName = args.pluginData.globalName;
295
- // Extract package name after '@namespace/' prefix
296
- // e.g., '@wordpress/blocks' or '@my-plugin/data'
297
- const packagePath = args.path
298
- .split( '/' )
299
- .slice( 1 )
300
- .join( '/' );
301
- const camelCasedName = camelCase( packagePath );
302
-
303
- return {
304
- contents: `module.exports = window.${ globalName }.${ camelCasedName };`,
305
- loader: 'js',
306
- };
307
- }
394
+ const parts = [
395
+ `'dependencies' => array(${ dependenciesString })`,
396
+ ];
397
+ if ( moduleDependenciesString ) {
398
+ parts.push(
399
+ `'module_dependencies' => array(${ moduleDependenciesString })`
400
+ );
401
+ }
402
+ parts.push( `'version' => '${ version }'` );
403
+ const assetContent = `<?php return array(${ parts.join(
404
+ ', '
405
+ ) });`;
406
+
407
+ const outputDir =
408
+ outputOptions.dir ||
409
+ path.dirname( outputOptions.file || 'build' );
410
+
411
+ const assetFilePath = path.join(
412
+ outputDir,
413
+ `${ assetName }.asset.php`
308
414
  );
309
415
 
310
- build.onEnd(
311
- /** @param {import('esbuild').BuildResult} result */
312
- async ( result ) => {
313
- if ( result.errors.length > 0 ) {
314
- return;
315
- }
316
-
317
- // Format module dependencies as array of arrays with 'id' and 'import' keys
318
- const moduleDependenciesArray = Array.from(
319
- moduleDependencies.entries()
320
- )
321
- .sort( ( [ a ], [ b ] ) => a.localeCompare( b ) )
322
- .map(
323
- ( [ dep, kind ] ) =>
324
- `array('id' => '${ dep }', 'import' => '${ kind }')`
325
- );
326
-
327
- const moduleDependenciesString =
328
- moduleDependenciesArray.length > 0
329
- ? moduleDependenciesArray.join( ', ' )
330
- : '';
331
-
332
- // Only generate asset file if requested
333
- if ( ! generateAssetFile ) {
334
- return;
335
- }
336
-
337
- // Merge discovered dependencies with extra dependencies
338
- const allDependencies = new Set( [
339
- ...dependencies,
340
- ...extraDependencies,
341
- ] );
342
-
343
- const dependenciesString = Array.from( allDependencies )
344
- .sort()
345
- .map( ( dep ) => `'${ dep }'` )
346
- .join( ', ' );
347
-
348
- // Determine output file path from build config
349
- let outputFilePath;
350
- if ( build.initialOptions.outfile ) {
351
- outputFilePath = build.initialOptions.outfile;
352
- } else if ( build.initialOptions.outdir ) {
353
- // Construct expected output filename from assetName
354
- // e.g., assetName='index.min' -> 'index.min.js'
355
- outputFilePath = path.join(
356
- build.initialOptions.outdir,
357
- `${ assetName }.js`
358
- );
359
- }
360
-
361
- // Collect files to hash
362
- const filesToHash = [];
363
- if ( outputFilePath ) {
364
- filesToHash.push( outputFilePath );
365
- }
366
-
367
- // Generate content-based version hash
368
- const version =
369
- await generateContentHash( filesToHash );
370
-
371
- const parts = [
372
- `'dependencies' => array(${ dependenciesString })`,
373
- ];
374
- if ( moduleDependenciesString ) {
375
- parts.push(
376
- `'module_dependencies' => array(${ moduleDependenciesString })`
377
- );
378
- }
379
- parts.push( `'version' => '${ version }'` );
380
- const assetContent = `<?php return array(${ parts.join(
381
- ', '
382
- ) });`;
383
-
384
- const outputDir =
385
- build.initialOptions.outdir ||
386
- path.dirname(
387
- build.initialOptions.outfile || 'build'
388
- );
389
-
390
- const assetFilePath = path.join(
391
- outputDir,
392
- `${ assetName }.asset.php`
393
- );
394
-
395
- await mkdir( path.dirname( assetFilePath ), {
396
- recursive: true,
397
- } );
398
- await writeFile( assetFilePath, assetContent );
399
- }
400
- );
416
+ await mkdir( path.dirname( assetFilePath ), {
417
+ recursive: true,
418
+ } );
419
+ await writeFile( assetFilePath, assetContent );
401
420
  },
402
421
  };
403
422
  };