build scratch-gui from source instead of using its build output

This commit is contained in:
Christopher Willis-Ford 2020-08-11 16:21:14 -07:00
parent 78d75dc3cf
commit f3b8251408
6 changed files with 27 additions and 66 deletions

View file

@ -18,7 +18,6 @@
"nets": "^3.2.0", "nets": "^3.2.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"scratch-gui": "github:LLK/scratch-gui#scratch-desktop", "scratch-gui": "github:LLK/scratch-gui#scratch-desktop",
"source-map-loader": "^0.2.4",
"uuid": "^8.0.0" "uuid": "^8.0.0"
} }
} }

21
package-lock.json generated
View file

@ -15577,27 +15577,6 @@
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
}, },
"source-map-loader": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/source-map-loader/-/source-map-loader-0.2.4.tgz",
"integrity": "sha512-OU6UJUty+i2JDpTItnizPrlpOIBLmQbWMuBg9q5bVtnHACqw1tn9nNwqJLbv0/00JjnJb/Ee5g5WS5vrRv7zIQ==",
"dev": true,
"requires": {
"async": "^2.5.0",
"loader-utils": "^1.1.0"
},
"dependencies": {
"async": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==",
"dev": true,
"requires": {
"lodash": "^4.17.14"
}
}
}
},
"source-map-resolve": { "source-map-resolve": {
"version": "0.5.3", "version": "0.5.3",
"resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz",

View file

@ -6,9 +6,9 @@
"version": "3.13.1", "version": "3.13.1",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"scripts": { "scripts": {
"clean": "rimraf ./dist ./static/assets && node ./scripts/npm-in-gui.js run clean", "clean": "rimraf ./dist ./static/assets",
"start": "electron-webpack dev --bail --display-error-details --env.minify=false", "start": "electron-webpack dev --bail --display-error-details --env.minify=false",
"compile": "npm run build-gui && electron-webpack --bail --display-error-details --env.minify=false", "compile": "electron-webpack --bail --display-error-details --env.minify=false",
"fetch": "rimraf ./static/assets/ && mkdirp ./static/assets/ && node ./scripts/fetchMediaLibraryAssets.js", "fetch": "rimraf ./static/assets/ && mkdirp ./static/assets/ && node ./scripts/fetchMediaLibraryAssets.js",
"build": "npm run build:dev", "build": "npm run build:dev",
"build:dev": "npm run compile && npm run doBuild -- --mode=dev", "build:dev": "npm run compile && npm run doBuild -- --mode=dev",
@ -19,9 +19,6 @@
"distDev": "npm run clean && npm run compile && npm run fetch && npm run doBuild -- --mode=dev", "distDev": "npm run clean && npm run compile && npm run fetch && npm run doBuild -- --mode=dev",
"test": "npm run test:lint", "test": "npm run test:lint",
"test:lint": "eslint --cache --color --ext .jsx,.js .", "test:lint": "eslint --cache --color --ext .jsx,.js .",
"postinstall": "node ./scripts/npm-in-gui.js install",
"build-gui": "node ./scripts/npm-in-gui.js run build",
"watch-gui": "node ./scripts/npm-in-gui.js run watch",
"rebuild-deps": "node ./scripts/rebuild-deps.js" "rebuild-deps": "node ./scripts/rebuild-deps.js"
}, },
"repository": { "repository": {
@ -129,7 +126,6 @@
"scratch-svg-renderer": "0.2.0-prerelease.20200610220938", "scratch-svg-renderer": "0.2.0-prerelease.20200610220938",
"scratch-vm": "0.2.0-prerelease.20200720182258", "scratch-vm": "0.2.0-prerelease.20200720182258",
"selenium-webdriver": "3.6.0", "selenium-webdriver": "3.6.0",
"source-map-loader": "^0.2.4",
"startaudiocontext": "1.2.1", "startaudiocontext": "1.2.1",
"style-loader": "^0.23.0", "style-loader": "^0.23.0",
"svg-to-image": "1.1.3", "svg-to-image": "1.1.3",

View file

@ -1,25 +0,0 @@
const childProcess = require('child_process');
const path = require('path');
// process.argv: ['node', 'run-in-gui.js', 'foo', ...]
const args = process.argv.slice(2);
// copy environment (including PATH) then add or replace BUILD_MODE and STATIC_PATH
const env = {
...process.env,
BUILD_MODE: 'dist',
STATIC_PATH: 'static'
};
const child = childProcess.spawnSync(
'npm', args,
{
cwd: path.join('node_modules', 'scratch-gui'),
env,
shell: true,
stdio: 'inherit'
}
);
if (child.error) throw child.error;
process.exit(child.status);

View file

@ -1,4 +1,5 @@
const childProcess = require('child_process'); const childProcess = require('child_process');
const path = require('path');
const electronPath = require('electron'); const electronPath = require('electron');
const webpack = require('webpack'); const webpack = require('webpack');
@ -49,9 +50,8 @@ const makeConfig = function (defaultConfig, options) {
const shouldDisable = options.disableDefaultRulesForExtensions.some( const shouldDisable = options.disableDefaultRulesForExtensions.some(
ext => rule.test.test(`test.${ext}`) ext => rule.test.test(`test.${ext}`)
); );
if (shouldDisable) { const statusWord = shouldDisable ? 'Discarding' : 'Keeping';
console.log(`${options.name}: Discarding electron-webpack default rule for ${rule.test}`); console.log(`${options.name}: ${statusWord} electron-webpack default rule for ${rule.test}`);
}
return !shouldDisable; return !shouldDisable;
}); });
} }
@ -67,11 +67,6 @@ const makeConfig = function (defaultConfig, options) {
loader: 'babel-loader', loader: 'babel-loader',
options: babelOptions options: babelOptions
}, },
{
test: sourceFileTest,
loader: 'source-map-loader',
enforce: 'pre'
},
{ // coped from scratch-gui { // coped from scratch-gui
test: /\.css$/, test: /\.css$/,
use: [{ use: [{
@ -114,7 +109,12 @@ const makeConfig = function (defaultConfig, options) {
].concat(options.plugins || []), ].concat(options.plugins || []),
resolve: { resolve: {
cacheWithContext: false, cacheWithContext: false,
symlinks: false symlinks: false,
alias: {
// act like scratch-gui has this line in its package.json:
// "browser": "./src/index.js"
'scratch-gui$': path.resolve(__dirname, 'node_modules', 'scratch-gui', 'src', 'index.js')
}
} }
}); });
}; };

View file

@ -10,14 +10,26 @@ module.exports = defaultConfig =>
{ {
name: 'renderer', name: 'renderer',
useReact: true, useReact: true,
disableDefaultRulesForExtensions: ['js', 'jsx', 'css', 'svg', 'png', 'wav', 'gif', 'jpg'], disableDefaultRulesForExtensions: ['js', 'jsx', 'css', 'svg', 'png', 'wav', 'gif', 'jpg', 'ttf'],
babelPaths: [ babelPaths: [
path.resolve(__dirname, 'src', 'renderer') path.resolve(__dirname, 'src', 'renderer'),
/node_modules[\\/]+scratch-[^\\/]+[\\/]+src/,
/node_modules[\\/]+pify/,
/node_modules[\\/]+@vernier[\\/]+godirect/
], ],
plugins: [ plugins: [
new CopyWebpackPlugin([{ new CopyWebpackPlugin([{
from: path.resolve(__dirname, 'node_modules', 'scratch-gui', 'dist', 'static'), from: 'node_modules/scratch-blocks/media',
to: 'static' to: 'static/blocks-media'
}]),
new CopyWebpackPlugin([{
from: 'extension-worker.{js,js.map}',
context: 'node_modules/scratch-vm/dist/web'
}]),
new CopyWebpackPlugin([{
from: 'src/lib/libraries/*.json',
to: 'static/libraries',
flatten: true
}]) }])
] ]
} }