mirror of
https://github.com/SwingTheVine/Wplace-BlueMarble.git
synced 2026-03-11 17:15:38 +00:00
Potentially fixed issues with sourcemap creation
This commit is contained in:
parent
99c30f67ea
commit
c40b5373e9
7 changed files with 19 additions and 21 deletions
|
|
@ -1,9 +1,9 @@
|
|||
/** Builds the userscript using esbuild.
|
||||
* This will:
|
||||
* 1. Update the package version across the entire project
|
||||
* 2. Bundle the JS files into one file
|
||||
* 3. Bundle the CSS files into one file
|
||||
* 4. Compress & obfuscate the bundled JS file
|
||||
* 2. Bundle the JS files into one file (esbuild)
|
||||
* 3. Bundle the CSS files into one file (esbuild)
|
||||
* 4. Compress & obfuscate the bundled JS file (terner)
|
||||
* 5. Create a sourcemap
|
||||
* @since 0.0.6
|
||||
*/
|
||||
|
|
@ -18,6 +18,8 @@ const require = createRequire(import.meta.url);
|
|||
// CommonJS imports (require)
|
||||
const terser = require('terser');
|
||||
|
||||
const isGitHub = !!process.env.GITHUB_ACTIONS; // Is this running in a GitHub Action Workflow?
|
||||
|
||||
// Tries to bump the version
|
||||
try {
|
||||
const update = execSync('node build/update-version.js', { stdio: 'inherit' });
|
||||
|
|
@ -49,25 +51,21 @@ const resultEsbuild = await esbuild.build({
|
|||
bundle: true, // Should the code be bundled?
|
||||
outfile: 'dist/BlueMarble.user.js', // The file the bundled code is exported to
|
||||
format: 'iife', // What format the bundler bundles the code into
|
||||
drop: process.env?.GITHUB_ACTIONS ? ['console', 'debugger'] : [], // Tells esbuild to remove console and debug logs if this file is run in a GitHub (Actions) Workflow
|
||||
target: 'es2020', // What is the minimum version/year that should be supported? When omited, it attempts to support backwards compatability with legacy browsers
|
||||
platform: 'browser', // The platform the bundled code will be operating on
|
||||
sourcemap: true, // Should a sourcemap be generated?
|
||||
legalComments: 'inline', // What level of legal comments are preserved? (Hard: none, Soft: inline)
|
||||
minify: false, // Should the code be minified?
|
||||
write: false // Should we write the outfile?
|
||||
}).catch(() => process.exit(1));
|
||||
|
||||
// Retrieves the JS file and map file
|
||||
// Retrieves the JS file
|
||||
const resultEsbuildJS = resultEsbuild.outputFiles.find(file => file.path.endsWith('.js'));
|
||||
const resultEsbuildMap = resultEsbuild.outputFiles.find(file => file.path.endsWith('.js.map'));
|
||||
|
||||
// Obfuscates the JS file
|
||||
const resultTerser = await terser.minify(resultEsbuildJS.text, {
|
||||
sourceMap: {
|
||||
content: resultEsbuildMap.text, // esbuild sourcemap
|
||||
filename: 'dist/BlueMarble.user.js', // The file to make a sourcemap for
|
||||
url: 'dist/BlueMarble.user.js.map' // The sourcemap to be made
|
||||
url: ' ' // (This setting is intentional) The sourcemap url to point to.
|
||||
},
|
||||
mangle: {
|
||||
toplevel: true, // Obfuscate top-level class/function names
|
||||
|
|
@ -81,9 +79,9 @@ const resultTerser = await terser.minify(resultEsbuildJS.text, {
|
|||
},
|
||||
},
|
||||
compress: {
|
||||
dead_code: true, // Should unreachable code be removed?
|
||||
drop_console: true, // Should console code be removed?
|
||||
drop_debugger: true, // SHould debugger code be removed?
|
||||
dead_code: isGitHub, // Should unreachable code be removed?
|
||||
drop_console: isGitHub, // Should console code be removed?
|
||||
drop_debugger: isGitHub, // Should debugger code be removed?
|
||||
passes: 2 // Number of times the compression algorithm runs
|
||||
},
|
||||
format: {
|
||||
|
|
|
|||
6
dist/BlueMarble.user.js
vendored
6
dist/BlueMarble.user.js
vendored
File diff suppressed because one or more lines are too long
2
dist/BlueMarble.user.js.map
vendored
2
dist/BlueMarble.user.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -35,7 +35,7 @@
|
|||
<a href="https://github.com/SwingTheVine/Wplace-BlueMarble/blob/main/LICENSE.txt" target="_blank"><img alt="Software License: MPL-2.0" src="https://img.shields.io/badge/Software_License-MPL--2.0-brightgreen?style=flat"></a>
|
||||
<a href="https://discord.gg/tpeBPy46hf" target="_blank"><img alt="Contact Me" src="https://img.shields.io/badge/Contact_Me-gray?style=flat&logo=Discord&logoColor=white&logoSize=auto&labelColor=cornflowerblue"></a>
|
||||
<a href="" target="_blank"><img alt="WakaTime" src="https://img.shields.io/badge/Coding_Time-35hrs_30mins-blue?style=flat&logo=wakatime&logoColor=black&logoSize=auto&labelColor=white"></a>
|
||||
<a href="" target="_blank"><img alt="Total Patches" src="https://img.shields.io/badge/Total_Patches-178-black?style=flat"></a>
|
||||
<a href="" target="_blank"><img alt="Total Patches" src="https://img.shields.io/badge/Total_Patches-188-black?style=flat"></a>
|
||||
<a href="" target="_blank"><img alt="Total Lines of Code" src="https://tokei.rs/b1/github/SwingTheVine/Wplace-BlueMarble?category=code"></a>
|
||||
<a href="" target="_blank"><img alt="Total Comments" src="https://tokei.rs/b1/github/SwingTheVine/Wplace-BlueMarble?category=comments"></a>
|
||||
<a href="" target="_blank"><img alt="Build" src="https://github.com/SwingTheVine/Wplace-BlueMarble/actions/workflows/build.yml/badge.svg"></a>
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "wplace-bluemarble",
|
||||
"version": "0.46.26",
|
||||
"version": "0.47.10",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wplace-bluemarble",
|
||||
"version": "0.46.26",
|
||||
"version": "0.47.10",
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"terser": "^5.43.1"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "wplace-bluemarble",
|
||||
"version": "0.47.0",
|
||||
"version": "0.47.10",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "node build/build.js",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name Blue Marble
|
||||
// @namespace https://github.com/SwingTheVine/
|
||||
// @version 0.47.0
|
||||
// @version 0.47.10
|
||||
// @description A userscript to automate and/or enhance the user experience on Wplace.live. Make sure to comply with the site's Terms of Service, and rules! This script is not affiliated with Wplace.live in any way, use at your own risk. This script is not affiliated with TamperMonkey. The author of this userscript is not responsible for any damages, issues, loss of data, or punishment that may occur as a result of using this script. This script is provided "as is" under the MPL-2.0 license. The "Blue Marble" icon is licensed under CC0 1.0 Universal (CC0 1.0) Public Domain Dedication. The image is owned by NASA.
|
||||
// @author SwingTheVine
|
||||
// @license MPL-2.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue