@@ -12,7 +12,7 @@ import child from "node:child_process";
1212import path from "node:path" ;
1313import chalk from "chalk" ;
1414import enquirer from "enquirer" ;
15- import { build } from "./tasks/build.js" ;
15+ import { buildDefaultFiles } from "./tasks/build.js" ;
1616
1717var releaseVersion ,
1818 nextVersion ,
@@ -33,7 +33,8 @@ var releaseVersion,
3333 versionFile = path . join ( "src" , "version.js" ) ,
3434
3535 releaseDir = "CDN" ,
36- distDir = "dist" ;
36+ distDir = "dist" ,
37+ distModuleDir = "dist-module" ;
3738
3839steps (
3940 initialize ,
@@ -160,7 +161,7 @@ function updateVersions( next ) {
160161}
161162
162163async function buildRelease ( next ) {
163- await build ( { version : releaseVersion } ) ;
164+ await buildDefaultFiles ( { version : releaseVersion } ) ;
164165 next ( ) ;
165166}
166167
@@ -174,11 +175,16 @@ function makeReleaseCopies( next ) {
174175 var releaseFiles = {
175176 "jquery-migrate-VER.js" : passThrough ,
176177 "jquery-migrate-VER.min.js" : fixMinRef ,
177- "jquery-migrate-VER.min.map" : fixMapRef
178+ "jquery-migrate-VER.min.map" : fixMapRef ,
179+ "jquery-migrate-VER.module.js" : passThrough ,
180+ "jquery-migrate-VER.module.min.js" : fixMinRef ,
181+ "jquery-migrate-VER.module.min.map" : fixMapRef
178182 } ;
179183 Object . keys ( releaseFiles ) . forEach ( function ( key ) {
180184 var distFile = key . replace ( / - V E R / g, "" ) ,
181- distPath = path . join ( distDir , distFile ) ,
185+ distPath = distFile . includes ( ".module." ) ?
186+ path . join ( distModuleDir , distFile ) :
187+ path . join ( distDir , distFile ) ,
182188 releaseFile = key . replace ( / V E R / g, releaseVersion ) ,
183189 releasePath = path . join ( releaseDir , releaseFile ) ;
184190
@@ -314,7 +320,7 @@ function writeJsonSync( fname, json ) {
314320}
315321
316322function fixMinRef ( oldText ) {
317- var mapRef = new RegExp ( "^//# sourceMappingURL=jquery-migrate.min .map\\n?" , "m" ) ;
323+ var mapRef = new RegExp ( "^//# sourceMappingURL=jquery-migrate\\..*\\ .map\\n?" , "m" ) ;
318324
319325 // Remove the ref for now rather than try to fix it
320326 var newText = oldText . replace ( mapRef , "" ) ;
@@ -327,13 +333,21 @@ function fixMinRef( oldText ) {
327333function fixMapRef ( oldText , newFile ) {
328334 var mapJSON = JSON . parse ( oldText ) ;
329335 var sources = mapJSON . sources ;
330- if ( sources . join ( ) !== "../src/migratemute.js,jquery-migrate.js" ) {
336+ if ( sources . join ( ) !== "../src/migratemute.js,jquery-migrate.js" &&
337+ sources . join ( ) !== "../src/migratemute.js,jquery-migrate.module.js" ) {
331338 throw Error ( "fixMapRef: Unexpected sources entry: " + sources ) ;
332339 }
333340
334341 // This file isn't published, not sure the best way to deal with that
335342 sources [ 0 ] = "migratemute.js" ;
336- sources [ 1 ] = newFile . replace ( / \. m a p $ / , ".js" ) ;
343+ sources [ 1 ] = newFile . replace ( / \. m i n \. m a p $ / , ".js" ) ;
344+
345+ // Path to the minified file for which this is the map.
346+ // The minified file is originally created from a versionless file,
347+ // so this field needs to be regenerated to contain the version
348+ // if `newFile` contains it.
349+ mapJSON . file = newFile . replace ( / \. m i n \. m a p $ / , ".min.js" ) ;
350+
337351 return JSON . stringify ( mapJSON ) ;
338352}
339353
0 commit comments