Use old bundle locations for parcel targets

This commit is contained in:
Jordan Eldredge 2023-02-05 15:03:35 -08:00
parent cfa960745d
commit a49a2f08bc
2 changed files with 6 additions and 43 deletions

View file

@ -5,6 +5,7 @@
"main": "dist/webamp-lazy-browser/webampLazyBrowser.js",
"files": [
"dist/webamp-*",
"built",
"dist/types"
],
"types": "dist/types/js/webamp.d.ts",
@ -41,14 +42,17 @@
"source": "demo/index.html"
}
},
"webamp-browser": "built/webamp.bundle.js",
"webamp-browser-min": "built/webamp.bundle.min.js",
"webamp-lazy-browser": "built/webamp.lazy-bundle.js",
"webamp-lazy-browser-min": "built/webamp.lazy-bundle.min.js",
"scripts": {
"lint-fix": "eslint . --ext ts,tsx,js --fix",
"lint": "eslint . --ext ts,tsx,js",
"type-check": "tsc",
"build": "parcel build --target demo-site",
"build-library": "parcel build --target webamp-browser --target webamp-browser-min --target webamp-lazy-browser --target webamp-lazy-browser-min --target types --reporter @parcel/reporter-bundle-analyzer",
"move-library": "node scripts/moveLibrary.js",
"prepublishOnly": "npm run build-library && npm run move-library && npm run type-check",
"prepublishOnly": "npm run build-library && npm run type-check",
"publish-next": "yarn publish --new-version=\"0.0.0-next-$(git rev-parse --short HEAD)\" --tag next",
"serve": "http-server ./dist/demo-site",
"start": "parcel demo/index.html",

View file

@ -1,41 +0,0 @@
// mkdir built; cp dist/webamp-browser-min/webampBrowser.js built/webamp.bundle.min.js && cp dist/webamp-lazy-browser-min/webampLazyBrowser.js built/webamp.lazy-bundle.min.js
// Script to replicate the location of build artifacts that existed in the old Webpack build.
const fs = require("fs");
const path = require("path");
const BUILD_DIR = path.join(__dirname, "../built");
const DIST_DIR = path.join(__dirname, "../dist");
const TARGETS = [
{
parcelPath: "webamp-browser/webampBrowser.js",
webpackName: "webamp.bundle.js",
},
{
parcelPath: "webamp-browser-min/webampBrowser.js",
webpackName: "webamp.bundle.min.js",
},
{
parcelPath: "webamp-lazy-browser/webampLazyBrowser.js",
webpackName: "webamp.lazy-bundle.js",
},
{
parcelPath: "webamp-lazy-browser-min/webampLazyBrowser.js",
webpackName: "webamp.lazy-bundle.min.js",
},
];
fs.mkdirSync(BUILD_DIR, { recursive: true });
console.log("Copying build artifacts to their old Webpack locations:");
for (const target of TARGETS) {
const from = path.join(DIST_DIR, target.parcelPath);
const to = path.join(BUILD_DIR, target.webpackName);
fs.copyFileSync(from, to);
console.log(`Copied "${from}" to "${to}".`);
const fromMap = `${from}.map`;
const toMap = `${to}.map`;
console.log(`Copied "${fromMap}" to "${toMap}".`);
fs.copyFileSync(fromMap, toMap);
}