@wordpress/build 0.5.1-next.06ee73755.0 → 0.5.1-next.ba3aee3a2.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.
Files changed (2) hide show
  1. package/lib/build.mjs +42 -58
  2. package/package.json +3 -4
package/lib/build.mjs CHANGED
@@ -17,7 +17,6 @@ import rtlcss from 'rtlcss';
17
17
  import cssnano from 'cssnano';
18
18
  import babel from 'esbuild-plugin-babel';
19
19
  import { camelCase } from 'change-case';
20
- import { NodePackageImporter } from 'sass-embedded';
21
20
 
22
21
  /**
23
22
  * Internal dependencies
@@ -108,59 +107,26 @@ const wordpressExternalsPlugin = createWordpressExternalsPlugin(
108
107
  HANDLE_PREFIX
109
108
  );
110
109
 
111
- /**
112
- * Get SASS options for the given working directory.
113
- *
114
- * Uses NodePackageImporter from sass-embedded for resolving package imports
115
- * (like @wordpress/base-styles) which works with any package manager (npm, pnpm, yarn).
116
- *
117
- * @param {string} workingDir - The directory where we're working (for NodePackageImporter).
118
- * @return {Object} SASS options object with importers and loadPaths.
119
- */
120
- function getSassOptions( workingDir ) {
121
- return {
122
- importers: [ new NodePackageImporter( workingDir ) ],
123
- // loadPaths for resolving @wordpress/base-styles imports and local base-styles imports
124
- loadPaths: [
125
- // Package's own node_modules (for pnpm isolated deps)
126
- path.join( workingDir, 'node_modules' ),
127
- // Root node_modules (for npm hoisted deps)
128
- path.join( ROOT_DIR, 'node_modules' ),
129
- // For local imports like @use "mixins"
130
- path.join( PACKAGES_DIR, 'base-styles' ),
131
- ],
132
- };
133
- }
134
-
135
- /**
136
- * Create style bundling plugins with the given working directory.
137
- *
138
- * @param {string} workingDir - The directory where we're working (for NodePackageImporter).
139
- * @return {object[]} Array of esbuild plugins for handling CSS/SCSS.
140
- */
141
- function createStyleBundlingPlugins( workingDir ) {
142
- const sassOptions = getSassOptions( workingDir );
143
- return [
144
- // Handle CSS modules (.module.css and .module.scss)
145
- sassPlugin( {
146
- embedded: true,
147
- filter: /\.module\.(css|scss)$/,
148
- transform: postcssModules( {
149
- generateScopedName: '[name]__[local]__[hash:base64:5]',
150
- } ),
151
- type: 'style',
152
- ...sassOptions,
153
- } ),
154
- // Handle regular CSS/SCSS files
155
- // Note: .module.css and .module.scss already handled by plugin above
156
- sassPlugin( {
157
- embedded: true,
158
- filter: /\.(css|scss)$/,
159
- type: 'style',
160
- ...sassOptions,
110
+ const styleBundlingPlugins = [
111
+ // Handle CSS modules (.module.css and .module.scss)
112
+ sassPlugin( {
113
+ embedded: true,
114
+ filter: /\.module\.(css|scss)$/,
115
+ transform: postcssModules( {
116
+ generateScopedName: '[name]__[local]__[hash:base64:5]',
161
117
  } ),
162
- ];
163
- }
118
+ type: 'style',
119
+ loadPaths: [ 'node_modules', path.join( PACKAGES_DIR, 'base-styles' ) ],
120
+ } ),
121
+ // Handle regular CSS/SCSS files
122
+ // Note: .module.css and .module.scss already handled by plugin above
123
+ sassPlugin( {
124
+ embedded: true,
125
+ filter: /\.(css|scss)$/,
126
+ type: 'style',
127
+ loadPaths: [ 'node_modules', path.join( PACKAGES_DIR, 'base-styles' ) ],
128
+ } ),
129
+ ];
164
130
 
165
131
  /**
166
132
  * Normalize path separators for cross-platform compatibility.
@@ -233,12 +199,16 @@ function momentTimezoneAliasPlugin() {
233
199
 
234
200
  // Cached paths - resolved lazily on first use
235
201
  let preBuiltBundlePath;
202
+ let momentTimezoneUtilsPath;
236
203
  const resolvePaths = () => {
237
204
  if ( preBuiltBundlePath ) {
238
205
  return;
239
206
  }
240
207
  preBuiltBundlePath = require.resolve(
241
- 'moment-timezone/builds/moment-timezone-with-data-1970-2030.js'
208
+ 'moment-timezone/builds/moment-timezone-with-data-1970-2030'
209
+ );
210
+ momentTimezoneUtilsPath = require.resolve(
211
+ 'moment-timezone/moment-timezone-utils.js'
242
212
  );
243
213
  };
244
214
 
@@ -251,6 +221,17 @@ function momentTimezoneAliasPlugin() {
251
221
  }
252
222
  );
253
223
 
224
+ // For utils, we need to load it but ensure it works with the pre-built bundle.
225
+ // The utils file tries to require('./') which would load index.js.
226
+ // We need to make sure it gets the pre-built bundle instead.
227
+ build.onResolve(
228
+ { filter: /^moment-timezone\/moment-timezone-utils$/ },
229
+ () => {
230
+ resolvePaths();
231
+ return { path: momentTimezoneUtilsPath };
232
+ }
233
+ );
234
+
254
235
  // Intercept the require('./') call inside moment-timezone-utils
255
236
  // and redirect it to the pre-built bundle.
256
237
  build.onResolve( { filter: /^\.\/$/ }, ( args ) => {
@@ -1111,7 +1092,7 @@ async function transpilePackage( packageName ) {
1111
1092
  const plugins = [
1112
1093
  needsEmotionPlugin && emotionPlugin,
1113
1094
  externalizeAllExceptCssPlugin,
1114
- ...createStyleBundlingPlugins( packageDir ),
1095
+ ...styleBundlingPlugins,
1115
1096
  ].filter( Boolean );
1116
1097
 
1117
1098
  if ( packageJson.main ) {
@@ -1245,7 +1226,10 @@ async function compileStyles( packageName ) {
1245
1226
  plugins: [
1246
1227
  sassPlugin( {
1247
1228
  embedded: true,
1248
- ...getSassOptions( packageDir ),
1229
+ loadPaths: [
1230
+ 'node_modules',
1231
+ path.join( PACKAGES_DIR, 'base-styles' ),
1232
+ ],
1249
1233
  async transform( source ) {
1250
1234
  // Process with autoprefixer for LTR version
1251
1235
  const ltrResult = await postcss( [
@@ -1430,7 +1414,7 @@ async function buildRoute( routeName ) {
1430
1414
  [],
1431
1415
  true // Generate asset file for minified build
1432
1416
  ),
1433
- ...createStyleBundlingPlugins( routeDir ),
1417
+ ...styleBundlingPlugins,
1434
1418
  ],
1435
1419
  } ),
1436
1420
  esbuild.build( {
@@ -1448,7 +1432,7 @@ async function buildRoute( routeName ) {
1448
1432
  [],
1449
1433
  false // Skip asset file for non-minified build
1450
1434
  ),
1451
- ...createStyleBundlingPlugins( routeDir ),
1435
+ ...styleBundlingPlugins,
1452
1436
  ],
1453
1437
  } ),
1454
1438
  ] );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/build",
3
- "version": "0.5.1-next.06ee73755.0",
3
+ "version": "0.5.1-next.ba3aee3a2.0",
4
4
  "description": "Build tool for WordPress plugins.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -48,8 +48,7 @@
48
48
  "moment-timezone": "^0.5.40",
49
49
  "postcss": "8.4.38",
50
50
  "postcss-modules": "6.0.1",
51
- "rtlcss": "4.3.0",
52
- "sass-embedded": "^1.97.2"
51
+ "rtlcss": "4.3.0"
53
52
  },
54
53
  "devDependencies": {
55
54
  "@types/node": "^20.17.10"
@@ -77,5 +76,5 @@
77
76
  "publishConfig": {
78
77
  "access": "public"
79
78
  },
80
- "gitHead": "fd315436f44683a993d5f053789b5279d95b2872"
79
+ "gitHead": "67d2e486fcd40c753591cf911ca0659132f519ca"
81
80
  }