feat: webpack 5

This commit is contained in:
cha0s 2023-11-30 21:41:42 -06:00
parent c25544b411
commit f039f7b8f6
109 changed files with 2355 additions and 1653 deletions

View File

@ -3,6 +3,80 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/monorepo
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
### Bug Fixes
* dox ([2d7c2f9](https://github.com/cha0s/flecks/commit/2d7c2f93dc673e12ce02263d54a2f8b309ed29fe))
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Bug Fixes
* async for parity ([780fa43](https://github.com/cha0s/flecks/commit/780fa433e156fbc7adad0f97aaebd3c821f40dee))
* avoid FOUC on dev ([18e2bb9](https://github.com/cha0s/flecks/commit/18e2bb9446b2ead51800f2dd2d094cbe8c6282f8))
* babel devs always breaking things ([cc8a35a](https://github.com/cha0s/flecks/commit/cc8a35a4b25ee730feb8cb1c978d3f29238e1f64))
* coerce the number ([820e390](https://github.com/cha0s/flecks/commit/820e390744d9a16a145db72c2ea7a433d2273d57))
* complex aliasing ([4ba2b51](https://github.com/cha0s/flecks/commit/4ba2b5113657f4426d8e976fe9a77d797378475a))
* conditional electron inclusion ([a959722](https://github.com/cha0s/flecks/commit/a9597225ca250fd9acee28c3feb284a979ee3111))
* core neutrino config ([7feac4a](https://github.com/cha0s/flecks/commit/7feac4a87b711ec9e48fa5b41be6d52b251a4e61))
* default source-map-support install ([ed2aa6a](https://github.com/cha0s/flecks/commit/ed2aa6a3c1354d7dfc4290e431c50779b8be2437))
* doc ([9a5fb07](https://github.com/cha0s/flecks/commit/9a5fb07d81fea6b5bb915ef2efe5973c186392aa))
* fake context ([3976078](https://github.com/cha0s/flecks/commit/3976078bebdf426bd2fa027f8d4e553149a14d02))
* hook dox ([aa78144](https://github.com/cha0s/flecks/commit/aa7814462801a9fef2324b8b5be231f288f23179))
* mocha error propagation ([1f11aac](https://github.com/cha0s/flecks/commit/1f11aac027e0699b821c2bc9f31bdfe3fd61a2d0))
* paths got broken somehow ([c7bbc48](https://github.com/cha0s/flecks/commit/c7bbc48d3a4c4db2b57c1002b73f4baac0b80172))
* test fails -> nonzero process code ([1f01189](https://github.com/cha0s/flecks/commit/1f0118914393d8b16913aad25eef81aaadac4e68))
* tests ([a982224](https://github.com/cha0s/flecks/commit/a98222495ebffa555db426e480e5f453148c240a))
### Features
* "wtf, you can't just take @babel/register, give it an actual API, and make it work simultaneously across multiple roots" ([82e22c3](https://github.com/cha0s/flecks/commit/82e22c3eef69f13b6b8645667d3362d49d3b3e6b))
* add electron for dox ([3e5a90d](https://github.com/cha0s/flecks/commit/3e5a90db648662a49bb7988df401a416ada153a2))
* awesomerific module resolution ([60c844d](https://github.com/cha0s/flecks/commit/60c844d58b294df0d9cf0be741266fdd8dd53a33))
* crazy hax to make our ESLint experience dope ([467f0c9](https://github.com/cha0s/flecks/commit/467f0c9ad30521f841665a7b939ad4d9b7c8b53c))
* electron ([67723d1](https://github.com/cha0s/flecks/commit/67723d1d356af94a1bbbc38c734722d4409ba057))
* electron with start-server-webpack-plugin ([1ade829](https://github.com/cha0s/flecks/commit/1ade8294a1d825cfa4361daa245c50ff05f6fa79))
* **electron:** devtools ([10d59e1](https://github.com/cha0s/flecks/commit/10d59e16edc6e8828c019fa728f19546a4c55042))
* html template specifier ([5791c7a](https://github.com/cha0s/flecks/commit/5791c7a89433f16c1efea045a00ab488975c6dab))
* per-entry styles ([d43316a](https://github.com/cha0s/flecks/commit/d43316a43635ea19338a6a1ce917f9b2d308c977))
* **react:** configure in web's absence ([754646d](https://github.com/cha0s/flecks/commit/754646d4a1df63de44f91e5a3184ebd9c75afd95))
* reopen closed ([11c61b3](https://github.com/cha0s/flecks/commit/11c61b3d7284cd8403660e71c314aba276244d8b))
* ServerFlecks::register(BuildConfig|Resolver) ([013f980](https://github.com/cha0s/flecks/commit/013f980f583277e2e48e74e53ff148f12ebb345a))
* support mjs ([7935597](https://github.com/cha0s/flecks/commit/79355977830a3778ef2414ece4d2812bc2e7ea0c))
* UserRequired ([9b5f6f4](https://github.com/cha0s/flecks/commit/9b5f6f4818afaec76ee941c8d2c4795912234ee8))
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)

View File

@ -32,4 +32,8 @@
# Next # Next
# Webpack 5
fixup no-param-reassign
warningsFilter deprecated
refactor stats

View File

@ -2,5 +2,5 @@
"packages": [ "packages": [
"packages/*" "packages/*"
], ],
"version": "1.4.1" "version": "2.0.3"
} }

View File

@ -5,31 +5,34 @@
"url": "https://github.com/cha0s/flecks.git" "url": "https://github.com/cha0s/flecks.git"
}, },
"scripts": { "scripts": {
"bfp": "for i in $(npx lerna exec pwd); do cd $i; bfp || break; done; cd ../..",
"build": "lerna run build", "build": "lerna run build",
"clean": "for i in $(npx lerna exec pwd); do cd $i; rm -rf yarn.lock node_modules; yarn; done; cd ../..",
"dox": "FLECKS_ENV_FLECKS_DOX_SERVER_filenameRewriters=\"{\\\"^@flecks/(.*):([0-9]+):([0-9]+)\\\": \\\"<a href='https://github.com/cha0s/flecks/tree/$(git rev-parse --short HEAD)/packages/\\$1#L\\$2'>@flecks/\\$1:\\$2:\\$3</a>\\\"}\" yarn flecks dox", "dox": "FLECKS_ENV_FLECKS_DOX_SERVER_filenameRewriters=\"{\\\"^@flecks/(.*):([0-9]+):([0-9]+)\\\": \\\"<a href='https://github.com/cha0s/flecks/tree/$(git rev-parse --short HEAD)/packages/\\$1#L\\$2'>@flecks/\\$1:\\$2:\\$3</a>\\\"}\" yarn flecks dox",
"lint": "lerna run lint", "lint": "lerna run lint",
"publish": "lerna publish --conventional-commits --contents=dist --registry https://registry.npmjs.org", "publish": "lerna publish --conventional-commits --contents=dist --registry https://registry.npmjs.org",
"refresh": "npm run clean && npm run bfp",
"test": "lerna run test --no-bail -- --silent" "test": "lerna run test --no-bail -- --silent"
}, },
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "*",
"@flecks/create-app": "^1.4.1", "@flecks/create-app": "*",
"@flecks/create-fleck": "^1.4.1", "@flecks/create-fleck": "*",
"@flecks/db": "^1.4.1", "@flecks/db": "*",
"@flecks/docker": "^1.4.1", "@flecks/docker": "*",
"@flecks/dox": "^1.4.1", "@flecks/dox": "*",
"@flecks/electron": "^1.4.1", "@flecks/electron": "*",
"@flecks/fleck": "^1.4.1", "@flecks/fleck": "*",
"@flecks/governor": "^1.4.1", "@flecks/governor": "*",
"@flecks/react": "^1.4.1", "@flecks/react": "*",
"@flecks/redis": "^1.4.1", "@flecks/redis": "*",
"@flecks/redux": "^1.4.1", "@flecks/redux": "*",
"@flecks/repl": "^1.4.1", "@flecks/repl": "*",
"@flecks/server": "^1.4.1", "@flecks/server": "*",
"@flecks/socket": "^1.4.1", "@flecks/socket": "*",
"@flecks/user": "^1.4.1", "@flecks/user": "*",
"@flecks/web": "^1.4.1", "@flecks/web": "*",
"lerna": "^3.22.1" "lerna": "^7.4.2"
} }
} }

View File

@ -3,6 +3,63 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/core
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
### Bug Fixes
* dox ([2d7c2f9](https://github.com/cha0s/flecks/commit/2d7c2f93dc673e12ce02263d54a2f8b309ed29fe))
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Bug Fixes
* babel devs always breaking things ([cc8a35a](https://github.com/cha0s/flecks/commit/cc8a35a4b25ee730feb8cb1c978d3f29238e1f64))
* coerce the number ([820e390](https://github.com/cha0s/flecks/commit/820e390744d9a16a145db72c2ea7a433d2273d57))
* complex aliasing ([4ba2b51](https://github.com/cha0s/flecks/commit/4ba2b5113657f4426d8e976fe9a77d797378475a))
* core neutrino config ([7feac4a](https://github.com/cha0s/flecks/commit/7feac4a87b711ec9e48fa5b41be6d52b251a4e61))
* default source-map-support install ([ed2aa6a](https://github.com/cha0s/flecks/commit/ed2aa6a3c1354d7dfc4290e431c50779b8be2437))
* fake context ([3976078](https://github.com/cha0s/flecks/commit/3976078bebdf426bd2fa027f8d4e553149a14d02))
* tests ([a982224](https://github.com/cha0s/flecks/commit/a98222495ebffa555db426e480e5f453148c240a))
### Features
* "wtf, you can't just take @babel/register, give it an actual API, and make it work simultaneously across multiple roots" ([82e22c3](https://github.com/cha0s/flecks/commit/82e22c3eef69f13b6b8645667d3362d49d3b3e6b))
* awesomerific module resolution ([60c844d](https://github.com/cha0s/flecks/commit/60c844d58b294df0d9cf0be741266fdd8dd53a33))
* crazy hax to make our ESLint experience dope ([467f0c9](https://github.com/cha0s/flecks/commit/467f0c9ad30521f841665a7b939ad4d9b7c8b53c))
* ServerFlecks::register(BuildConfig|Resolver) ([013f980](https://github.com/cha0s/flecks/commit/013f980f583277e2e48e74e53ff148f12ebb345a))
* support mjs ([7935597](https://github.com/cha0s/flecks/commit/79355977830a3778ef2414ece4d2812bc2e7ea0c))
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/core **Note:** Version bump only for package @flecks/core

View File

@ -1,4 +0,0 @@
const neutrino = require('neutrino');
// eslint-disable-next-line import/no-dynamic-require
module.exports = neutrino(require(`${__dirname}/.neutrinorc`)).eslintrc();

View File

@ -1,74 +0,0 @@
const {chmod} = require('fs');
const {join} = require('path');
const airbnb = require('@neutrinojs/airbnb');
const banner = require('@neutrinojs/banner');
const copy = require('@neutrinojs/copy');
const glob = require('glob');
const fleck = require('../src/bootstrap/fleck');
const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
const config = require('../src/bootstrap/fleck.neutrinorc');
// Dotfiles.
config.use.push(({config}) => {
['eslintrc'].forEach((filename) => {
config
.entry(`server/build/.${filename}`)
.clear()
.add(`./src/server/build/${filename}`);
})
});
// Tests.
config.use.push(({config}) => {
// Test entrypoint.
const testPaths = glob.sync(join(FLECKS_CORE_ROOT, 'test/*.js'));
testPaths.push(...glob.sync(join(FLECKS_CORE_ROOT, `test/platforms/server/*.js`)));
if (testPaths.length > 0) {
const testEntry = config.entry('test').clear();
testPaths.forEach((path) => testEntry.add(path));
}
});
// Fleck build configuration.
config.use.unshift(fleck());
// AirBnb linting.
config.use.unshift(
airbnb({
eslint: {
baseConfig: require('../src/server/build/.eslint.defaults'),
},
}),
);
// Include a shebang and set the executable bit..
config.use.push(banner({
banner: '#!/usr/bin/env node',
include: /^cli\.js$/,
pluginId: 'shebang',
raw: true,
}))
config.use.push(({config}) => {
config
.plugin('executable')
.use(class Executable {
apply(compiler) {
compiler.hooks.afterEmit.tapAsync(
'Executable',
(compilation, callback) => {
chmod(join(__dirname, '..', 'dist', 'cli.js'), 0o755, callback);
},
)
}
});
});
module.exports = config;

View File

@ -71,28 +71,28 @@ Have fun!
The flecks server provides an interface (`flecks.buildConfig()`) for gathering configuration files The flecks server provides an interface (`flecks.buildConfig()`) for gathering configuration files
from the `build` directory. The resolution order is determined by a few variables: from the `build` directory. The resolution order is determined by a few variables:
- `filename` specifies the name of the configuration file, e.g. `server.neutrinorc.js`. - `filename` specifies the name of the configuration file, e.g. `server.webpack.config.js`.
- `general` specifies a general variation of the given configuration. The general form of `server.neutrinorc.js` is `.neutrinorc.js`. - `general` specifies a general variation of the given configuration. The general form of `server.webpack.config.js` is `webpack.config.js`.
- `root` specifies an alternative location to search. Defaults to `FLECKS_CORE_ROOT`. - `root` specifies an alternative location to search. Defaults to `FLECKS_CORE_ROOT`.
- `fleck` specifies the fleck owning the configuration. `@flecks/server` owns `server.neutrinorc.js`. - `fleck` specifies the fleck owning the configuration. `@flecks/server` owns `server.webpack.config.js`.
Given these considerations, and supposing we had the above variables set like: Given these considerations, and supposing we had the above variables set like:
```javascript ```javascript
const filename = 'server.neutrinorc.js'; const filename = 'server.webpack.config.js';
const general = '.neutrinorc.js'; const general = 'webpack.config.js';
const root = '/foo/bar/baz'; const root = '/foo/bar/baz';
const fleck = '@flecks/server'; const fleck = '@flecks/server';
``` ```
Flecks will then search the following paths top-down until it finds the build configuration: Flecks will then search the following paths top-down until it finds the build configuration:
- `/foo/bar/baz/build/server.neutrinorc.js` - `/foo/bar/baz/build/server.webpack.config.js`
- `/foo/bar/baz/build/.neutrinorc.js` - `/foo/bar/baz/build/webpack.config.js`
- `${FLECKS_CORE_ROOT}/build/server.neutrinorc.js` - `${FLECKS_CORE_ROOT}/build/server.webpack.config.js`
- `${FLECKS_CORE_ROOT}/build/.neutrinorc.js` - `${FLECKS_CORE_ROOT}/build/webpack.config.js`
- `@flecks/server/build/server.neutrinorc.js` - `@flecks/server/build/server.webpack.config.js`
- `@flecks/server/build/.neutrinorc.js` - `@flecks/server/build/webpack.config.js`

View File

@ -161,7 +161,7 @@ export const hooks = {
If you think about the example above, you might realize that it will become a lot of typing to keep adding new models over time. Provider hooks exist to reduce this maintenance burden for you. If you think about the example above, you might realize that it will become a lot of typing to keep adding new models over time. Provider hooks exist to reduce this maintenance burden for you.
Webpack provides an API called [require.context](https://v4.webpack.js.org/guides/dependency-management/#requirecontext), and the flecks provider is optimized to work with this API. Webpack provides an API called [require.context](https://webpack.js.org/guides/dependency-management/#requirecontext), and the flecks provider is optimized to work with this API.
Supposing our fleck is structured like so: Supposing our fleck is structured like so:

View File

@ -1,26 +1,34 @@
export const hooks = { export const hooks = {
/** /**
* Hook into neutrino configuration. * Hook into webpack configuration.
* @param {string} target The build target; e.g. `server`. * @param {string} target The build target; e.g. `server`.
* @param {Object} config The neutrino configuration. * @param {Object} config The webpack configuration.
* @param {Object} env The webpack environment.
* @param {Object} argv The webpack commandline arguments.
* @see {@link https://webpack.js.org/configuration/configuration-types/#exporting-a-function}
*/ */
'@flecks/core.build': (target, config) => { '@flecks/core.build': (target, config, env, argv) => {
if ('something' === target) { if ('something' === target) {
config[target].use.push(someNeutrinoMiddleware); if ('production' === argv.mode) {
config.plugins.push(new SomePlugin());
}
} }
}, },
/** /**
* Alter build configurations after they have been hooked. * Alter build configurations after they have been hooked.
* @param {Object} configs The neutrino configurations. * @param {Object} configs The webpack configurations keyed by target.
* @param {Object} env The webpack environment.
* @param {Object} argv The webpack commandline arguments.
* @see {@link https://webpack.js.org/configuration/configuration-types/#exporting-a-function}
*/ */
'@flecks/core.build.alter': (configs) => { '@flecks/core.build.alter': (configs) => {
// Maybe we want to do something if a config exists..? // Maybe we want to do something if a target exists..?
if (configs.something) { if (configs.someTarget) {
// Do something... // Do something...
// And then maybe we want to remove it from the build configuration..? // And then maybe we want to remove it from the build configuration..? That's ok!
delete configs.something; delete configs.someTarget;
} }
}, },
@ -101,18 +109,7 @@ export const hooks = {
}, },
/** /**
* Define neutrino build targets. * Define build targets.
*/ */
'@flecks/core.targets': () => ['sometarget'], '@flecks/core.targets': () => ['sometarget'],
/**
* Hook into webpack configuration.
* @param {string} target The build target; e.g. `server`.
* @param {Object} config The neutrino configuration.
*/
'@flecks/core.webpack': (target, config) => {
if ('something' === target) {
config.stats = 'verbose';
}
},
}; };

View File

@ -0,0 +1,3 @@
const defaultConfigFn = require('../src/server/build/default.eslint.config');
module.exports = defaultConfigFn();

View File

@ -1,3 +1,8 @@
const neutrino = require('neutrino'); const configFn = require('../src/server/build/fleck.webpack.config');
const {executable} = require('../src/server/webpack');
module.exports = neutrino(require('./.neutrinorc')).webpack(); module.exports = (env, argv) => {
const config = configFn(env, argv);
config.plugins.push(...executable());
return config;
};

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"main": "index.js", "main": "index.js",
"author": "cha0s", "author": "cha0s",
"license": "MIT", "license": "MIT",
@ -18,7 +18,7 @@
"scripts": { "scripts": {
"build": "NODE_PATH=./node_modules webpack --config ./build/webpack.config.js --mode production", "build": "NODE_PATH=./node_modules webpack --config ./build/webpack.config.js --mode production",
"clean": "rm -rf dist node_modules yarn.lock && yarn", "clean": "rm -rf dist node_modules yarn.lock && yarn",
"lint": "NODE_PATH=./node_modules eslint --config ./build/.eslintrc.js --format codeframe --ext mjs,js .", "lint": "NODE_PATH=./node_modules eslint --config ./build/eslint.config.js .",
"postversion": "cp package.json dist", "postversion": "cp package.json dist",
"test": "npm run build && mocha -t 10000 --colors ./dist/test.js" "test": "npm run build && mocha -t 10000 --colors ./dist/test.js"
}, },
@ -30,14 +30,16 @@
"index.js.map", "index.js.map",
"server.js", "server.js",
"server.js.map", "server.js.map",
"server/build/.eslint.defaults.js",
"server/build/.eslint.defaults.js.map",
"server/build/.eslintrc.js",
"server/build/.eslintrc.js.map",
"server/build/babel.config.js", "server/build/babel.config.js",
"server/build/babel.config.js.map", "server/build/babel.config.js.map",
"server/build/webpack.config.js", "server/build/default.eslint.config.js",
"server/build/webpack.config.js.map", "server/build/default.eslint.config.js.map",
"server/build/eslint.config.js",
"server/build/eslint.config.js.map",
"server/build/fleck.webpack.config.js",
"server/build/fleck.webpack.config.js.map",
"server/build/fleckspack.config.js",
"server/build/fleckspack.config.js.map",
"src", "src",
"start.js", "start.js",
"start.js.map", "start.js.map",
@ -47,42 +49,51 @@
], ],
"dependencies": { "dependencies": {
"@babel/core": "^7.12.10", "@babel/core": "^7.12.10",
"@babel/eslint-parser": "^7.23.3",
"@babel/eslint-plugin": "^7.22.10",
"@babel/plugin-proposal-optional-chaining": "^7.12.16", "@babel/plugin-proposal-optional-chaining": "^7.12.16",
"@babel/plugin-transform-regenerator": "^7.16.7", "@babel/plugin-transform-regenerator": "^7.16.7",
"@babel/preset-env": "^7.12.11", "@babel/preset-env": "^7.12.11",
"@babel/register": "7.13.0", "@babel/register": "7.13.0",
"@neutrinojs/airbnb": "^9.4.0", "babel-loader": "^9.1.3",
"@neutrinojs/banner": "^9.4.0",
"@neutrinojs/clean": "^9.5.0",
"@neutrinojs/compile-loader": "^9.5.0",
"@neutrinojs/copy": "^9.4.0",
"babel-merge": "^3.0.0", "babel-merge": "^3.0.0",
"babel-plugin-prepend": "^1.0.2", "babel-plugin-prepend": "^1.0.2",
"chai": "4.2.0", "chai": "4.2.0",
"chai-as-promised": "7.1.1", "chai-as-promised": "7.1.1",
"commander": "^8.3.0", "commander": "^8.3.0",
"copy-webpack-plugin": "^11.0.0",
"debug": "4.3.1", "debug": "4.3.1",
"enhanced-resolve": "^5.9.2", "enhanced-resolve": "^5.9.2",
"eslint": "^7.0.0", "eslint": "^7.0.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-import-resolver-webpack": "0.13.0", "eslint-import-resolver-webpack": "0.13.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-webpack-plugin": "^4.0.1",
"glob": "^7.2.0",
"globals": "^13.23.0",
"js-yaml": "4.1.0", "js-yaml": "4.1.0",
"jsonparse": "^1.3.1", "jsonparse": "^1.3.1",
"lodash.flatten": "^4.4.0", "lodash.flatten": "^4.4.0",
"lodash.get": "^4.4.2", "lodash.get": "^4.4.2",
"lodash.intersection": "^4.4.0", "lodash.intersectionby": "4.7.0",
"lodash.set": "^4.3.2", "lodash.set": "^4.3.2",
"lodash.without": "^4.4.0", "lodash.without": "^4.4.0",
"neutrino": "^9.4.0", "path-browserify": "^1.0.1",
"pirates": "^4.0.5", "pirates": "^4.0.5",
"process": "^0.11.10",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"source-map-loader": "4.0.1",
"source-map-support": "0.5.19", "source-map-support": "0.5.19",
"supports-color": "9.2.1", "supports-color": "9.2.1",
"webpack": "^4", "webpack": "^5.89.0",
"webpack-cli": "^3", "webpack-cli": "^5.1.4",
"webpack-node-externals": "2.5.2" "webpack-node-externals": "^3.0.0"
}, },
"devDependencies": { "devDependencies": {
"glob": "^7.2.0",
"mocha": "^8.3.2" "mocha": "^8.3.2"
} }
} }

View File

@ -1,50 +0,0 @@
const {
basename,
dirname,
extname,
join,
} = require('path');
const R = require('./require');
const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
const resolveValidModulePath = (source) => (path) => {
// Does the file resolve as source?
try {
R.resolve(`${source}/${path}`);
return true;
}
catch (error) {
const ext = extname(path);
// Try the implicit [path]/index[.ext] variation.
try {
R.resolve(`${source}/${dirname(path)}/${basename(path, ext)}/index${ext}`);
return true;
}
catch (error) {
return false;
}
}
};
module.exports = () => ({config, options}) => {
const {packageJson: {name, files = []}, source} = options;
// index is not taken for granted.
config.entryPoints.delete('index');
// Alias this package.
config.resolve.alias
.set(name, join(FLECKS_CORE_ROOT, 'src'));
// Calculate entry points from `files`.
files
.filter(resolveValidModulePath(source))
.forEach((file) => {
const trimmed = join(dirname(file), basename(file, extname(file)));
config
.entry(trimmed)
.clear()
.add(`./src/${trimmed}`);
});
};

View File

@ -1,74 +0,0 @@
const clean = require('@neutrinojs/clean');
const compileLoader = require('@neutrinojs/compile-loader');
const babelMerge = require('babel-merge');
const nodeExternals = require('webpack-node-externals');
const R = require('./require');
module.exports = ({
babel = {},
targets = {
esmodules: true,
node: 'current',
},
} = {}) => (neutrino) => {
const {config, options} = neutrino;
const {name} = options.packageJson;
neutrino.use(
compileLoader({
include: [options.source, options.tests],
babel: babelMerge(
{
plugins: [R.resolve('@babel/plugin-syntax-dynamic-import')],
presets: [
[
R.resolve('@babel/preset-env'),
{
shippedProposals: true,
targets,
},
],
],
},
babel,
),
}),
);
neutrino.use(clean({cleanStaleWebpackAssets: false}));
/* eslint-disable indent */
config
.context(options.root)
.devtool('source-map')
.externals(nodeExternals({importType: 'umd'}))
.target('node')
.resolve
.extensions
.merge([
'.wasm',
...options.extensions.map((ext) => `.${ext}`),
'.json',
])
.end()
.end()
.stats({
children: false,
colors: true,
entrypoints: false,
modules: false,
})
.optimization
.splitChunks(false)
.runtimeChunk(false)
.end()
.output
.filename('[name].js')
.library(name)
.libraryTarget('umd')
.path(options.output)
.umdNamedDefine(true)
.end()
.node
.set('__dirname', false)
.set('__filename', false);
/* eslint-enable indent */
};

View File

@ -1,35 +0,0 @@
const copy = require('@neutrinojs/copy');
const autoentry = require('./autoentry');
const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
module.exports = {
options: {
output: 'dist',
root: FLECKS_CORE_ROOT,
},
use: [
copy({
copyUnmodified: true,
patterns: [
{
from: '.',
to: '.',
globOptions: {
dot: true,
ignore: [
'dist',
'node_modules',
],
gitignore: true,
},
},
],
pluginId: '@flecks/core.copy',
}),
autoentry(),
],
};

View File

@ -15,12 +15,4 @@ export const hooks = {
*/ */
id: 'flecks', id: 'flecks',
}), }),
'@flecks/core.build': (target, config) => {
config.use.push(({config}) => {
config.module
.rule('mjs$')
.test(/.mjs$/)
.type('javascript/auto');
});
},
}; };

View File

@ -1,50 +0,0 @@
module.exports = {
env: {
browser: true,
// @todo chase
es2021: true,
node: true,
mocha: true,
},
globals: {
__non_webpack_require__: true,
window: true,
},
ignorePatterns: [
'**/dist/**',
'build/dox/hooks.js',
],
overrides: [
{
files: [
'test/**/*.js',
],
rules: {
'babel/no-unused-expressions': 'off',
'brace-style': 'off',
'class-methods-use-this': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'max-classes-per-file': 'off',
'no-new': 'off',
'padded-blocks': 'off',
},
},
],
rules: {
'babel/object-curly-spacing': 'off',
'brace-style': ['error', 'stroustrup'],
'import/prefer-default-export': 'off',
'jsx-a11y/control-has-associated-label': ['error', {assert: 'either'}],
'jsx-a11y/label-has-associated-control': ['error', {assert: 'either'}],
'no-plusplus': 'off',
'no-shadow': 'off',
'padded-blocks': ['error', {classes: 'always'}],
yoda: 'off',
},
settings: {
'import/resolver': {
node: {},
},
},
};

View File

@ -10,10 +10,10 @@ module.exports = (api) => {
setSpreadProperties: true, setSpreadProperties: true,
}, },
plugins: [ plugins: [
'@babel/plugin-proposal-class-properties', '@babel/plugin-syntax-class-properties',
'@babel/plugin-proposal-logical-assignment-operators', '@babel/plugin-syntax-logical-assignment-operators',
'@babel/plugin-proposal-nullish-coalescing-operator', '@babel/plugin-syntax-nullish-coalescing-operator',
'@babel/plugin-proposal-optional-chaining', '@babel/plugin-syntax-optional-chaining',
], ],
presets: [ presets: [
[ [

View File

@ -0,0 +1,92 @@
const babelmerge = require('babel-merge');
const globals = require('globals');
const R = require('../../require');
module.exports = (flecks) => {
const merging = [
{
plugins: [R.resolve('@babel/plugin-syntax-dynamic-import')],
presets: [
[
R.resolve('@babel/preset-env'),
{
shippedProposals: true,
targets: {
esmodules: true,
node: 'current',
},
},
],
],
},
];
if (flecks) {
merging.push({configFile: flecks.buildConfig('babel.config.js')});
const rcBabel = flecks.babel();
merging.push(...rcBabel.map(([, babel]) => babel));
}
const babelConfig = babelmerge.all(merging);
return {
extends: [
R.resolve('eslint-config-airbnb'),
R.resolve('eslint-config-airbnb/hooks'),
],
globals: {
...globals.browser,
...globals.es2021,
...globals.mocha,
...globals.node,
__non_webpack_require__: true,
},
ignorePatterns: [
'**/dist/**',
'build/dox/hooks.js',
],
overrides: [
{
files: [
'test/**/*.js',
],
rules: {
'brace-style': 'off',
'class-methods-use-this': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'max-classes-per-file': 'off',
'no-new': 'off',
'no-unused-expressions': 'off',
'padded-blocks': 'off',
},
},
],
parser: R.resolve('@babel/eslint-parser'),
parserOptions: {
requireConfigFile: false,
babelOptions: babelConfig,
},
plugins: ['@babel'],
rules: {
'brace-style': ['error', 'stroustrup'],
// Bug: https://github.com/import-js/eslint-plugin-import/issues/2181
'import/no-import-module-exports': 'off',
'import/prefer-default-export': 'off',
'jsx-a11y/control-has-associated-label': ['error', {assert: 'either'}],
'jsx-a11y/label-has-associated-control': ['error', {assert: 'either'}],
'no-param-reassign': ['error', {props: false}],
'no-plusplus': 'off',
'no-shadow': 'off',
'object-curly-spacing': 'off',
'padded-blocks': ['error', {classes: 'always'}],
yoda: 'off',
},
settings: {
'import/resolver': {
node: {},
},
react: {
version: '18',
},
},
};
};

View File

@ -7,14 +7,10 @@ const {
} = require('fs'); } = require('fs');
const {join} = require('path'); const {join} = require('path');
const neutrino = require('neutrino');
const R = require('../../bootstrap/require');
const D = require('../../debug'); const D = require('../../debug');
const {targetNeutrino, targetNeutrinos} = require('../commands');
const {default: Flecks} = require('../flecks'); const {default: Flecks} = require('../flecks');
const debug = D('@flecks/core/.eslintrc.js'); const debug = D('@flecks/core/server/build/eslint.config.js');
const { const {
FLECKS_CORE_BUILD_TARGET = 'fleck', FLECKS_CORE_BUILD_TARGET = 'fleck',
@ -28,14 +24,8 @@ if (FLECKS_CORE_SYNC_FOR_ESLINT) {
debug('bootstrapping flecks...'); debug('bootstrapping flecks...');
const flecks = Flecks.bootstrap(); const flecks = Flecks.bootstrap();
debug('bootstrapped'); debug('bootstrapped');
const neutrinos = targetNeutrinos(flecks); const eslintConfig = flecks.buildConfig('eslint.config.js', FLECKS_CORE_BUILD_TARGET);
const config = neutrinos[targetNeutrino(FLECKS_CORE_BUILD_TARGET)] const webpackConfig = flecks.buildConfig('webpack.config.js', FLECKS_CORE_BUILD_TARGET);
? await R(neutrinos[targetNeutrino(FLECKS_CORE_BUILD_TARGET)])(flecks)
// eslint-disable-next-line global-require
: require('../../../build/.neutrinorc');
flecks.invokeFlat('@flecks/core.build', FLECKS_CORE_BUILD_TARGET, config);
const eslintConfig = neutrino(config).eslintrc();
const webpackConfig = neutrino(config).webpack();
eslintConfig.settings['import/resolver'].webpack = { eslintConfig.settings['import/resolver'].webpack = {
config: { config: {
resolve: webpackConfig.resolve, resolve: webpackConfig.resolve,
@ -45,10 +35,10 @@ if (FLECKS_CORE_SYNC_FOR_ESLINT) {
})(); })();
} }
else { else {
const cacheDirectory = join(FLECKS_CORE_ROOT, 'node_modules', '.cache', 'flecks'); const cacheDirectory = join(FLECKS_CORE_ROOT, 'node_modules', '.cache', '@flecks', 'core');
try { try {
statSync(join(cacheDirectory, 'eslintrc.json')); statSync(join(cacheDirectory, 'eslint.config.json'));
module.exports = JSON.parse(readFileSync(join(cacheDirectory, 'eslintrc.json')).toString()); module.exports = JSON.parse(readFileSync(join(cacheDirectory, 'eslint.config.json')).toString());
} }
catch (error) { catch (error) {
// Just silly. By synchronously spawning... ourselves, the spawned copy can use async. // Just silly. By synchronously spawning... ourselves, the spawned copy can use async.
@ -64,7 +54,7 @@ else {
try { try {
statSync(join(FLECKS_CORE_ROOT, 'node_modules')); statSync(join(FLECKS_CORE_ROOT, 'node_modules'));
mkdirSync(cacheDirectory, {recursive: true}); mkdirSync(cacheDirectory, {recursive: true});
writeFileSync(join(cacheDirectory, 'eslintrc.json'), json); writeFileSync(join(cacheDirectory, 'eslint.config.json'), json);
} }
// eslint-disable-next-line no-empty // eslint-disable-next-line no-empty
catch (error) {} catch (error) {}

View File

@ -0,0 +1,135 @@
const {
basename,
dirname,
extname,
join,
} = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const glob = require('glob');
const ESLintPlugin = require('eslint-webpack-plugin');
const R = require('../../require');
const {defaultConfig, externals} = require('../webpack');
const eslintConfigFn = require('./default.eslint.config');
const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
const source = join(FLECKS_CORE_ROOT, 'src');
const tests = join(FLECKS_CORE_ROOT, 'test');
const resolveValidModulePath = (source) => (path) => {
// Does the file resolve as source?
try {
R.resolve(`${source}/${path}`);
}
catch (error) {
const ext = extname(path);
// Try the implicit [path]/index[.ext] variation.
try {
R.resolve(`${source}/${dirname(path)}/${basename(path, ext)}/index${ext}`);
}
catch (error) {
return false;
}
}
return true;
};
module.exports = (env, argv, flecks) => {
const {name, files = []} = R(join(FLECKS_CORE_ROOT, 'package.json'));
const config = defaultConfig(flecks, {
externals: externals({importType: 'umd'}),
node: {
__dirname: false,
__filename: false,
},
optimization: {
splitChunks: false,
runtimeChunk: false,
},
output: {
filename: '[name].js',
library: {
name,
type: 'umd',
umdNamedDefine: true,
},
},
plugins: [
new CopyPlugin({
patterns: [
{
from: '.',
to: '.',
globOptions: {
dot: true,
ignore: [
'dist',
'node_modules',
],
gitignore: true,
},
info: {
minimized: true,
},
},
],
}),
],
resolve: {
alias: {
[name]: source,
},
fallback: {
child_process: false,
fs: false,
path: R.resolve('path-browserify'),
process: R.resolve('process/browser'),
stream: false,
},
},
stats: {
colors: true,
errorDetails: true,
},
target: 'node',
});
const eslint = eslintConfigFn(flecks);
eslint.settings['import/resolver'].webpack = {
config: {
resolve: config.resolve,
},
};
config.plugins.push(
new ESLintPlugin({
cache: true,
cwd: FLECKS_CORE_ROOT,
emitWarning: argv.mode !== 'production',
failOnError: argv.mode === 'production',
useEslintrc: false,
overrideConfig: eslint,
}),
);
// Automatic entry registration.
files
.filter(resolveValidModulePath(source))
.forEach((file) => {
const trimmed = join(dirname(file), basename(file, extname(file)));
config.entry[trimmed] = `${source}/${trimmed}`;
});
// Test entry.
const testPaths = glob.sync(join(tests, '*.js'));
const platforms = flecks
? flecks.platforms
: ['server'];
for (let i = 0; i < platforms.length; ++i) {
testPaths.push(...glob.sync(join(tests, `platforms/${platforms[i]}/*.js`)));
}
if (testPaths.length > 0) {
config.entry.test = testPaths;
}
return config;
};

View File

@ -0,0 +1,95 @@
/* eslint-disable import/first */
import 'source-map-support/register';
if ('production' !== process.env.NODE_ENV) {
try {
// eslint-disable-next-line global-require, import/no-unresolved
__non_webpack_require__('dotenv/config');
}
// eslint-disable-next-line no-empty
catch (error) {}
}
import intersectionBy from 'lodash.intersectionby';
import D from '../../debug';
import Flecks from '../flecks';
const debug = D('@flecks/core/server/build/fleckspack.config.js');
const debugSilly = debug.extend('silly');
const {
FLECKS_CORE_BUILD_LIST = '',
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
const buildList = FLECKS_CORE_BUILD_LIST
.split(',')
.map((name) => name.trim())
.filter((e) => e);
export default async (env, argv) => {
debug('bootstrapping flecks...');
const flecks = Flecks.bootstrap();
debug('bootstrapped');
debug('gathering configs');
const targets = [];
Object.entries(flecks.invoke('@flecks/core.targets'))
.forEach(([fleck, fleckTargets]) => {
intersectionBy(fleckTargets, buildList.length ? buildList : fleckTargets)
.forEach((target) => {
targets.push([target, fleck]);
});
});
debug('building: %O', targets.map(([target]) => target));
if (0 === targets.length) {
debug('no build configuration found! aborting...');
await new Promise(() => {});
}
const entries = await Promise.all(targets.map(
async ([target, fleck]) => {
const buildConfig = flecks.resolveBuildConfig(
[
FLECKS_CORE_ROOT,
flecks.resolvePath(fleck),
],
[
`${target}.webpack.config.js`,
'webpack.config.js',
],
);
const configFn = __non_webpack_require__(buildConfig);
if ('function' !== typeof configFn) {
debug(`'${
target
}' build configuration expected function got ${
typeof configFn
}! aborting...`);
return undefined;
}
return [target, await configFn(env, argv, flecks)];
},
));
await Promise.all(
entries.map(async ([target, config]) => (
flecks.invokeFlat('@flecks/core.build', target, config, env, argv)
)),
);
const webpackConfigs = Object.fromEntries(entries);
await Promise.all(flecks.invokeFlat('@flecks/core.build.alter', webpackConfigs, env, argv));
const enterableWebpackConfigs = Object.values(webpackConfigs)
.filter((webpackConfig) => {
if (!webpackConfig.entry) {
debug('webpack configurations %O had no entry... discarding', webpackConfig);
return false;
}
return true;
});
if (0 === enterableWebpackConfigs.length) {
debug('no webpack configuration found! aborting...');
await new Promise(() => {});
}
debugSilly('webpack configurations %O', enterableWebpackConfigs);
return enterableWebpackConfigs;
};

View File

@ -1,84 +0,0 @@
/* eslint-disable import/first */
import 'source-map-support/register';
if ('production' !== process.env.NODE_ENV) {
try {
// eslint-disable-next-line global-require, import/no-unresolved
require('dotenv/config');
}
// eslint-disable-next-line no-empty
catch (error) {}
}
import flatten from 'lodash.flatten';
import intersection from 'lodash.intersection';
import neutrino from 'neutrino';
import D from '../../debug';
import {targetNeutrino} from '../commands';
import Flecks from '../flecks';
const debug = D('@flecks/core/build/webpack.config.js');
const debugSilly = debug.extend('silly');
const {
FLECKS_CORE_BUILD_LIST = '',
} = process.env;
const buildList = FLECKS_CORE_BUILD_LIST
.split(',')
.map((name) => name.trim())
.filter((e) => e);
export default (async () => {
debug('bootstrapping flecks...');
const flecks = Flecks.bootstrap();
debug('bootstrapped');
debug('gathering configs');
let targets = flatten(flecks.invokeFlat('@flecks/core.targets'));
if (buildList.length > 0) {
targets = intersection(targets, buildList);
}
debug('building: %O', targets);
if (0 === targets.length) {
debug('no build configuration found! aborting...');
await new Promise(() => {});
}
const entries = await Promise.all(targets.map(
async (target) => [
target,
await __non_webpack_require__(process.env[targetNeutrino(target)])(flecks),
],
));
await Promise.all(
entries.map(async ([target, config]) => (
flecks.invokeFlat('@flecks/core.build', target, config)
)),
);
const neutrinoConfigs = Object.fromEntries(entries);
await Promise.all(flecks.invokeFlat('@flecks/core.build.alter', neutrinoConfigs));
const webpackConfigs = (
await Promise.all(
Object.entries(neutrinoConfigs)
.map(async ([target, config]) => {
const webpackConfig = neutrino(config).webpack();
await flecks.invokeFlat('@flecks/core.webpack', target, webpackConfig);
return webpackConfig;
}),
)
)
.filter((webpackConfig) => {
if (!webpackConfig.entry) {
debug('webpack configurations %O had no entry... discarding', webpackConfig);
return false;
}
return true;
});
if (0 === webpackConfigs.length) {
debug('no webpack configuration found! aborting...');
await new Promise(() => {});
}
debugSilly('webpack configurations %O', webpackConfigs);
return webpackConfigs;
})();

View File

@ -37,41 +37,8 @@ export const spawnWith = (cmd, opts = {}) => {
child.stdout.pipe(process.stdout); child.stdout.pipe(process.stdout);
return child; return child;
}; };
export const targetNeutrino = (target) => (
`FLECKS_CORE_BUILD_TARGET_${
target
.toUpperCase()
.replace(/[^A-Za-z0-9]/g, '_')
}_NEUTRINO`
);
export const targetNeutrinos = (flecks) => {
const entries = Object.entries(flecks.invoke('@flecks/core.targets'));
const targetNeutrinos = {};
for (let i = 0; i < entries.length; ++i) {
const [fleck, targets] = entries[i];
targets
.forEach((target) => {
targetNeutrinos[targetNeutrino(target)] = flecks.resolveBuildConfig(
[
FLECKS_CORE_ROOT,
flecks.resolvePath(fleck),
],
[
`${target}.neutrinorc.js`,
'.neutrinorc.js',
],
);
});
}
return targetNeutrinos;
};
export default (program, flecks) => { export default (program, flecks) => {
Object.entries(targetNeutrinos(flecks))
.forEach(([key, value]) => {
process.env[key] = value;
});
const commands = { const commands = {
clean: { clean: {
description: 'remove node_modules, lock file, build artifacts, then reinstall', description: 'remove node_modules, lock file, build artifacts, then reinstall',
@ -112,10 +79,9 @@ export default (program, flecks) => {
watch, watch,
} = opts; } = opts;
debug('Building...', opts); debug('Building...', opts);
const webpackConfig = flecks.buildConfig('webpack.config.js'); const webpackConfig = flecks.buildConfig('fleckspack.config.js');
const cmd = [ const cmd = [
'npx', 'webpack', 'npx', 'webpack',
'--colors',
'--config', webpackConfig, '--config', webpackConfig,
'--mode', (production && !hot) ? 'production' : 'development', '--mode', (production && !hot) ? 'production' : 'development',
...((watch || hot) ? ['--watch'] : []), ...((watch || hot) ? ['--watch'] : []),
@ -124,7 +90,6 @@ export default (program, flecks) => {
cmd, cmd,
{ {
env: { env: {
...targetNeutrinos(flecks),
...(target ? {FLECKS_CORE_BUILD_LIST: target} : {}), ...(target ? {FLECKS_CORE_BUILD_LIST: target} : {}),
...(hot ? {FLECKS_ENV_FLECKS_SERVER_hot: 'true'} : {}), ...(hot ? {FLECKS_ENV_FLECKS_SERVER_hot: 'true'} : {}),
}, },
@ -159,7 +124,6 @@ export default (program, flecks) => {
{ {
env: { env: {
FLECKS_CORE_BUILD_TARGET: target, FLECKS_CORE_BUILD_TARGET: target,
...targetNeutrinos(flecks),
}, },
}, },
); );

View File

@ -12,14 +12,13 @@ import {
resolve, resolve,
} from 'path'; } from 'path';
import compileLoader from '@neutrinojs/compile-loader';
import babelmerge from 'babel-merge'; import babelmerge from 'babel-merge';
import enhancedResolve from 'enhanced-resolve'; import enhancedResolve from 'enhanced-resolve';
import {addHook} from 'pirates'; import {addHook} from 'pirates';
import R from '../bootstrap/require';
import D from '../debug'; import D from '../debug';
import Flecks from '../flecks'; import Flecks from '../flecks';
import R from '../require';
import Compiler from './compiler'; import Compiler from './compiler';
const { const {
@ -119,10 +118,15 @@ export default class ServerFlecks extends Flecks {
if (!config) { if (!config) {
throw new Error(`Unknown build config '${path}'`); throw new Error(`Unknown build config '${path}'`);
} }
const paths = []; const paths = [`${specific}.${path}`];
if (config.specifier) { if ('specifier' in config) {
if (false === config.specifier) {
paths.pop();
}
else {
paths.push(config.specifier(specific)); paths.push(config.specifier(specific));
} }
}
paths.push(path); paths.push(path);
const roots = [config.root]; const roots = [config.root];
if (config.root !== FLECKS_CORE_ROOT) { if (config.root !== FLECKS_CORE_ROOT) {
@ -493,12 +497,14 @@ export default class ServerFlecks extends Flecks {
} }
static resolveBuildConfig(resolver, roots, paths) { static resolveBuildConfig(resolver, roots, paths) {
const tried = [];
for (let i = 0; i < roots.length; ++i) { for (let i = 0; i < roots.length; ++i) {
const root = roots[i]; const root = roots[i];
for (let j = 0; j < paths.length; ++j) { for (let j = 0; j < paths.length; ++j) {
const path = paths[j]; const path = paths[j];
const resolved = join(root, 'build', path); const resolved = join(root, 'build', path);
try { try {
tried.push(resolved);
statSync(resolved); statSync(resolved);
return resolved; return resolved;
} }
@ -506,7 +512,7 @@ export default class ServerFlecks extends Flecks {
catch (error) {} catch (error) {}
} }
} }
throw new Error(`Couldn't resolve build file '${paths.pop()}'`); throw new Error(`Couldn't resolve build file '${paths.pop()}', tried: ${tried.join(', ')}`);
} }
resolvePath(path) { resolvePath(path) {
@ -544,12 +550,7 @@ export default class ServerFlecks extends Flecks {
return undefined; return undefined;
} }
runtimeCompiler(resolver, runtime, neutrino, {additionalModuleDirs = [], allowlist = []} = {}) { runtimeCompiler(resolver, runtime, config, {additionalModuleDirs = [], allowlist = []} = {}) {
const {config} = neutrino;
// Pull the default compiler.
if (config.module.rules.has('compile')) {
config.module.rules.delete('compile');
}
// Compile. // Compile.
const needCompilation = Object.entries(resolver) const needCompilation = Object.entries(resolver)
.filter(([fleck]) => this.constructor.fleckIsCompiled(resolver, fleck)); .filter(([fleck]) => this.constructor.fleckIsCompiled(resolver, fleck));
@ -565,8 +566,7 @@ export default class ServerFlecks extends Flecks {
: this.constructor.sourcepath(R.resolve(this.constructor.resolve(resolver, fleck))); : this.constructor.sourcepath(R.resolve(this.constructor.resolve(resolver, fleck)));
alias = alias.endsWith('/index') ? alias.slice(0, -6) : alias; alias = alias.endsWith('/index') ? alias.slice(0, -6) : alias;
allowlist.push(fleck); allowlist.push(fleck);
config.resolve.alias config.resolve.alias[fleck] = alias;
.set(fleck, alias);
debugSilly('%s runtime de-externalized %s, alias: %s', runtime, fleck, alias); debugSilly('%s runtime de-externalized %s, alias: %s', runtime, fleck, alias);
}); });
// Set up compilation at each root. // Set up compilation at each root.
@ -587,12 +587,23 @@ export default class ServerFlecks extends Flecks {
// Augment the compiler with babel config from flecksrc. // Augment the compiler with babel config from flecksrc.
...babelmerge.all(rcBabel.map(([, babel]) => babel)), ...babelmerge.all(rcBabel.map(([, babel]) => babel)),
}; };
compileLoader({ config.module.rules.push(
ignore: [sourceroot], {
test: /\.(m?jsx?)?$/,
include: [sourceroot], include: [sourceroot],
babel, use: [
ruleId: `@flecks/${runtime}/runtime/compile[${root}]`, {
})(neutrino); loader: R.resolve('babel-loader'),
options: {
cacheDirectory: true,
babelrc: false,
configFile: false,
...babel,
},
},
],
},
);
}); });
} }
} }

View File

@ -1,11 +1,11 @@
import {join} from 'path'; import {join} from 'path';
import {inspect} from 'util'; import {inspect} from 'util';
import airbnb from '@neutrinojs/airbnb'; import ESLintPlugin from 'eslint-webpack-plugin';
import neutrino from 'neutrino'; import webpack from 'webpack';
import eslintConfigFn from './build/default.eslint.config';
import commands from './commands'; import commands from './commands';
import R from '../bootstrap/require';
const { const {
FLECKS_CORE_ROOT = process.cwd(), FLECKS_CORE_ROOT = process.cwd(),
@ -22,46 +22,45 @@ export {
default as commands, default as commands,
processCode, processCode,
spawnWith, spawnWith,
targetNeutrino,
targetNeutrinos,
} from './commands'; } from './commands';
export {default as Flecks} from './flecks'; export {default as Flecks} from './flecks';
export {default as fleck} from '../bootstrap/fleck'; export {default as require} from '../require';
export {default as require} from '../bootstrap/require';
export {JsonStream, transform} from './stream'; export {JsonStream, transform} from './stream';
export * from './webpack';
export {webpack};
export const hooks = { export const hooks = {
'@flecks/core.build': (target, config, flecks) => { '@flecks/core.build': (target, config, env, argv, flecks) => {
const { const {
'eslint.exclude': exclude, 'eslint.exclude': exclude,
profile, profile,
} = flecks.get('@flecks/core/server'); } = flecks.get('@flecks/core/server');
if (-1 !== profile.indexOf(target)) { if (profile.includes(target)) {
config.use.push(({config}) => { config.plugins.push(
config new webpack.debug.ProfilingPlugin({
.plugin('profiler') outputPath: join(FLECKS_CORE_ROOT, `profile.build-${target}.json`),
.use( }),
R.resolve('webpack/lib/debug/ProfilingPlugin'),
[{outputPath: join(FLECKS_CORE_ROOT, `profile.build-${target}.json`)}],
); );
});
} }
if (-1 === exclude.indexOf(target)) { if (exclude.includes(target)) {
const baseConfig = R(flecks.buildConfig('.eslint.defaults.js', target)); const eslint = eslintConfigFn(flecks);
const webpackConfig = neutrino(config).webpack(); config.plugins.push(
config.use.unshift( new ESLintPlugin({
airbnb({ cache: true,
eslint: { cwd: FLECKS_CORE_ROOT,
baseConfig: { emitWarning: argv.mode !== 'production',
...baseConfig, failOnError: argv.mode === 'production',
useEslintrc: false,
overrideConfig: {
...eslint,
settings: { settings: {
...(baseConfig.settings || {}), ...(eslint.settings || {}),
'import/resolver': { 'import/resolver': {
...(baseConfig.settings['import/resolver'] || {}), ...(eslint.settings['import/resolver'] || {}),
webpack: { webpack: {
config: { config: {
resolve: webpackConfig.resolve, resolve: config.resolve,
},
}, },
}, },
}, },
@ -77,20 +76,20 @@ export const hooks = {
*/ */
'babel.config.js', 'babel.config.js',
/** /**
* ESLint defaults. The default .eslintrc.js just reads from this file so that the build * ESLint defaults. The default `eslint.config.js` just reads from this file so that the build
* process can dynamically configure parts of ESLint. * process can dynamically configure parts of ESLint.
*/ */
['.eslint.defaults.js', {specifier: (specific) => `${specific}.eslint.defaults.js`}], 'default.eslint.config.js',
/** /**
* ESLint configuration. See: https://eslint.org/docs/user-guide/configuring/ * ESLint configuration. See: https://eslint.org/docs/user-guide/configuring/
*/ */
['.eslintrc.js', {specifier: (specific) => `${specific}.eslintrc.js`}], 'eslint.config.js',
/** /**
* Neutrino build configuration. See: https://neutrinojs.org/usage/ * Flecks webpack configuration. See: https://webpack.js.org/configuration/
*/ */
['.neutrinorc.js', {specifier: (specific) => `${specific}.neutrinorc.js`}], ['fleckspack.config.js', {specifier: false}],
/** /**
* Webpack (v4) configuration. See: https://v4.webpack.js.org/configuration/ * Webpack configuration. See: https://webpack.js.org/configuration/
*/ */
'webpack.config.js', 'webpack.config.js',
], ],

View File

@ -0,0 +1,163 @@
const {chmod} = require('fs');
const {join} = require('path');
const babelmerge = require('babel-merge');
const CopyPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const D = require('../debug');
const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
const debug = D('@flecks/core/server/webpack');
const debugSilly = debug.extend('silly');
const source = join(FLECKS_CORE_ROOT, 'src');
const tests = join(FLECKS_CORE_ROOT, 'test');
exports.banner = (options) => (
new webpack.BannerPlugin({
entryOnly: true,
raw: true,
...options,
})
);
exports.copy = (options) => (new CopyPlugin(options));
exports.defaultConfig = (flecks, specializedConfig) => {
const extensions = ['.mjs', '.js', '.json', '.wasm'];
const merging = [
{
plugins: ['@babel/plugin-syntax-dynamic-import'],
presets: [
[
'@babel/preset-env',
{
shippedProposals: true,
targets: {
esmodules: true,
node: 'current',
},
},
],
],
},
];
if (flecks) {
extensions.push(...flecks.exts());
merging.push({configFile: flecks.buildConfig('babel.config.js')});
const rcBabel = flecks.babel();
debugSilly('.flecksrc: babel: %j', rcBabel);
merging.push(...rcBabel.map(([, babel]) => babel));
}
const babelConfig = babelmerge.all(merging);
const extensionsRegex = exports.regexFromExtensions(extensions);
const defaults = {
context: FLECKS_CORE_ROOT,
devtool: 'source-map',
entry: {},
module: {
rules: [
{
enforce: 'pre',
test: extensionsRegex,
use: ['source-map-loader'],
},
{
include: [source, tests],
test: extensionsRegex,
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
configFile: false,
...babelConfig,
},
},
],
},
],
},
output: {
clean: true,
path: join(FLECKS_CORE_ROOT, 'dist'),
},
plugins: [],
resolve: {
alias: {},
extensions,
fallback: {},
modules: [
'node_modules',
join(FLECKS_CORE_ROOT, 'node_modules'),
],
},
stats: {
colors: true,
errorDetails: true,
},
};
return 'function' === typeof specializedConfig
? specializedConfig(defaults)
: {
...defaults,
...specializedConfig,
module: {
...specializedConfig.module,
rules: [
...defaults.module.rules,
...(specializedConfig.module?.rules || []),
],
},
output: {
...defaults.output,
...specializedConfig.output,
},
plugins: [
...defaults.plugins,
...(specializedConfig.plugins || []),
],
resolve: {
...defaults.resolve,
...specializedConfig.resolve,
},
stats: {
...defaults.stats,
...specializedConfig.stats,
},
};
};
// Include a shebang and set the executable bit..
exports.executable = () => ([
exports.banner({
banner: '#!/usr/bin/env node',
include: /^cli\.js$/,
}),
new class Executable {
// eslint-disable-next-line class-methods-use-this
apply(compiler) {
compiler.hooks.afterEmit.tapAsync(
'Executable',
(compilation, callback) => {
chmod(join(FLECKS_CORE_ROOT, 'dist', 'cli.js'), 0o755, callback);
},
);
}
}(),
]);
exports.externals = nodeExternals;
exports.regexFromExtensions = (exts) => (
new RegExp(String.raw`(?:${exts.map((ext) => ext.replace('.', '\\.')).join('|')})$`)
);
exports.webpack = webpack;

View File

@ -24,9 +24,9 @@ export const hooks = {
O.foo *= 2; O.foo *= 2;
}, },
'@flecks/core/test/invoke-merge': () => ({foo: 69}), '@flecks/core/test/invoke-merge': () => ({foo: 69}),
'@flecks/core/test/invoke-merge-async': () => new Promise((resolve) => resolve({foo: 69})), '@flecks/core/test/invoke-merge-async': () => new Promise((resolve) => { resolve({foo: 69}); }),
'@flecks/core/test/invoke-merge-unique': () => ({foo: 69}), '@flecks/core/test/invoke-merge-unique': () => ({foo: 69}),
'@flecks/core/test/invoke-merge-unique-async': () => new Promise((resolve) => resolve({foo: 69})), '@flecks/core/test/invoke-merge-unique-async': () => new Promise((resolve) => { resolve({foo: 69}); }),
'@flecks/core/test.middleware': () => (foo, next) => { '@flecks/core/test.middleware': () => (foo, next) => {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
foo.bar += 1; foo.bar += 1;

View File

@ -13,9 +13,9 @@ export const hooks = {
}, 0); }, 0);
}), }),
'@flecks/core/test/invoke-merge': () => ({bar: 420}), '@flecks/core/test/invoke-merge': () => ({bar: 420}),
'@flecks/core/test/invoke-merge-async': () => new Promise((resolve) => resolve({bar: 420})), '@flecks/core/test/invoke-merge-async': () => new Promise((resolve) => { resolve({bar: 420}); }),
'@flecks/core/test/invoke-merge-unique': () => ({foo: 69}), '@flecks/core/test/invoke-merge-unique': () => ({foo: 69}),
'@flecks/core/test/invoke-merge-unique-async': () => new Promise((resolve) => resolve({foo: 69})), '@flecks/core/test/invoke-merge-unique-async': () => new Promise((resolve) => { resolve({foo: 69}); }),
'@flecks/core/test.middleware': () => (foo, next) => { '@flecks/core/test.middleware': () => (foo, next) => {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
foo.bar *= 2; foo.bar *= 2;

View File

@ -3,6 +3,44 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/create-app
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/create-app
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/create-app **Note:** Version bump only for package @flecks/create-app

View File

@ -1,51 +0,0 @@
/* eslint-disable import/no-extraneous-dependencies */
const {chmod} = require('fs');
const {join} = require('path');
const banner = require('@neutrinojs/banner');
const copy = require('@neutrinojs/copy');
module.exports = async (flecks) => {
// eslint-disable-next-line global-require
const config = await require('@flecks/fleck/server/build/fleck.neutrinorc')(flecks);
config.use.push(banner({
banner: '#!/usr/bin/env node',
include: /^cli\.js$/,
pluginId: 'shebang',
raw: true,
}));
config.use.push(({config}) => {
config
.plugin('executable')
.use(class Executable {
// eslint-disable-next-line class-methods-use-this
apply(compiler) {
compiler.hooks.afterEmit.tapAsync(
'Executable',
(compilation, callback) => {
chmod(join(__dirname, '..', 'dist', 'cli.js'), 0o755, callback);
},
);
}
});
});
config.use.push(
copy({
copyUnmodified: true,
patterns: [
{
from: 'template',
to: 'template',
},
],
}),
);
return config;
};

View File

@ -0,0 +1,17 @@
const {copy, executable} = require('@flecks/core/server');
// eslint-disable-next-line import/no-extraneous-dependencies
const configFn = require('@flecks/fleck/server/build/fleck.webpack.config');
module.exports = async (env, argv, flecks) => {
const config = await configFn(env, argv, flecks);
config.plugins.push(...executable());
config.plugins.push(copy({
patterns: [
{
from: 'template',
to: 'template',
},
],
}));
return config;
};

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"bin": { "bin": {
"create-app": "./cli.js" "create-app": "./cli.js"
}, },
@ -28,12 +28,12 @@
"template" "template"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"glob": "^7.2.0", "glob": "^7.2.0",
"minimatch": "^5.0.1", "minimatch": "^5.0.1",
"validate-npm-package-name": "^3.0.0" "validate-npm-package-name": "^3.0.0"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -9,11 +9,11 @@
"start": "DEBUG=@flecks*,flecks*,-@flecks/core/flecks* npm run dev" "start": "DEBUG=@flecks*,flecks*,-@flecks/core/flecks* npm run dev"
}, },
"dependencies": { "dependencies": {
"@flecks/core": "^1.0.0", "@flecks/core": "^2.0.0",
"@flecks/server": "^1.0.0" "@flecks/server": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"@flecks/create-fleck": "^1.0.0", "@flecks/create-fleck": "^2.0.0",
"lerna": "^3.22.1" "lerna": "^3.22.1"
} }
} }

View File

@ -3,6 +3,44 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/create-fleck
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/create-fleck
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/create-fleck **Note:** Version bump only for package @flecks/create-fleck

View File

@ -1,51 +0,0 @@
/* eslint-disable import/no-extraneous-dependencies */
const {chmod} = require('fs');
const {join} = require('path');
const banner = require('@neutrinojs/banner');
const copy = require('@neutrinojs/copy');
module.exports = async (flecks) => {
// eslint-disable-next-line global-require
const config = await require('@flecks/fleck/server/build/fleck.neutrinorc')(flecks);
config.use.push(banner({
banner: '#!/usr/bin/env node',
include: /^cli\.js$/,
pluginId: 'shebang',
raw: true,
}));
config.use.push(({config}) => {
config
.plugin('executable')
.use(class Executable {
// eslint-disable-next-line class-methods-use-this
apply(compiler) {
compiler.hooks.afterEmit.tapAsync(
'Executable',
(compilation, callback) => {
chmod(join(__dirname, '..', 'dist', 'cli.js'), 0o755, callback);
},
);
}
});
});
config.use.push(
copy({
copyUnmodified: true,
patterns: [
{
from: 'template',
to: 'template',
},
],
}),
);
return config;
};

View File

@ -0,0 +1,17 @@
const {copy, executable} = require('@flecks/core/server');
// eslint-disable-next-line import/no-extraneous-dependencies
const configFn = require('@flecks/fleck/server/build/fleck.webpack.config');
module.exports = async (env, argv, flecks) => {
const config = await configFn(env, argv, flecks);
config.plugins.push(...executable());
config.plugins.push(copy({
patterns: [
{
from: 'template',
to: 'template',
},
],
}));
return config;
};

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"bin": { "bin": {
"create-fleck": "./cli.js" "create-fleck": "./cli.js"
}, },
@ -26,10 +26,10 @@
"template" "template"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"@flecks/create-app": "^1.4.1" "@flecks/create-app": "^2.0.3"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -15,9 +15,9 @@
"test" "test"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.0.0" "@flecks/core": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.0.0" "@flecks/fleck": "^2.0.0"
} }
} }

View File

@ -3,6 +3,44 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/db
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/db
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/db **Note:** Version bump only for package @flecks/db

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
"clean": "flecks clean", "clean": "flecks clean",
@ -23,11 +23,11 @@
"src" "src"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"sequelize": "^6.3.5", "sequelize": "^6.3.5",
"sqlite3": "^5.0.2" "sqlite3": "^5.0.2"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -53,7 +53,9 @@ export async function createDatabaseConnection(flecks) {
} }
catch (error) { catch (error) {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
await new Promise((resolve) => setTimeout(resolve, 250)); await new Promise((resolve) => {
setTimeout(resolve, 250);
});
} }
} }
const dependencies = {}; const dependencies = {};

View File

@ -3,6 +3,44 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/docker
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/docker
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/docker **Note:** Version bump only for package @flecks/docker

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
@ -24,10 +24,10 @@
"src" "src"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"debug": "^4.3.3" "debug": "^4.3.3"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -79,7 +79,9 @@ export default async (flecks, key, config) => {
while (await !containerIsRunning(name)) { while (await !containerIsRunning(name)) {
debug("waiting for '%s' to start...", key); debug("waiting for '%s' to start...", key);
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
await new Promise((resolve) => setTimeout(resolve, 10)); await new Promise((resolve) => {
setTimeout(resolve, 10);
});
} }
debug("'%s' started", key); debug("'%s' started", key);
if (config.hasConnected) { if (config.hasConnected) {

View File

@ -3,6 +3,49 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/dox
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/dox
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Bug Fixes
* hook dox ([aa78144](https://github.com/cha0s/flecks/commit/aa7814462801a9fef2324b8b5be231f288f23179))
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/dox **Note:** Version bump only for package @flecks/dox

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
@ -27,11 +27,11 @@
"@babel/core": "^7.17.2", "@babel/core": "^7.17.2",
"@babel/traverse": "^7.17.0", "@babel/traverse": "^7.17.0",
"@babel/types": "^7.17.0", "@babel/types": "^7.17.0",
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"comment-parser": "^1.3.0", "comment-parser": "^1.3.0",
"glob": "^7.2.0" "glob": "^7.2.0"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -34,18 +34,31 @@ export const generateConfigPage = (configs) => {
Object.entries(configs) Object.entries(configs)
.sort(([l], [r]) => (l < r ? -1 : 1)) .sort(([l], [r]) => (l < r ? -1 : 1))
.forEach(([fleck, configs]) => { .forEach(([fleck, configs]) => {
source.push(`## \`${fleck}\``); // source.push(`## \`${fleck}\``);
source.push(''); source.push('```javascript');
source.push(`'${fleck}': {`);
configs.forEach(({comment, config, defaultValue}) => { configs.forEach(({comment, config, defaultValue}) => {
comment.split('\n').forEach((line) => { comment.split('\n').forEach((line) => {
source.push(`> ${line}`); source.push(` // ${line}`);
}); });
source.push(''); const value = defaultValue
source.push('```javascript'); .split('\n')
source.push(`${config}: ${defaultValue}`); .map((line, i, array) => {
let output = '';
if (array.length - 1 === i) {
output += ' ';
}
else if (0 !== i) {
output += ' ';
}
output += line.trim();
return output;
})
.join('\n');
source.push(` ${config}: ${value}`);
});
source.push('}');
source.push('```'); source.push('```');
source.push('');
});
}); });
return source.join('\n'); return source.join('\n');
}; };

View File

@ -293,12 +293,12 @@ export const parseFile = async (filename, resolved, state) => {
}; };
const fleckSources = async (path) => ( const fleckSources = async (path) => (
new Promise((r, e) => ( new Promise((r, e) => {
glob( glob(
join(path, 'src', '**', '*.js'), join(path, 'src', '**', '*.js'),
(error, result) => (error ? e(error) : r(result)), (error, result) => (error ? e(error) : r(result)),
) );
)) })
); );
export const parseFleckRoot = async (root, state) => { export const parseFleckRoot = async (root, state) => {

View File

@ -0,0 +1,49 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://git.hq.cha0s.io/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/electron
## [2.0.1](https://git.hq.cha0s.io/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/electron
# [2.0.0](https://git.hq.cha0s.io/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Bug Fixes
* conditional electron inclusion ([a959722](https://git.hq.cha0s.io/cha0s/flecks/commits/a9597225ca250fd9acee28c3feb284a979ee3111))
* doc ([9a5fb07](https://git.hq.cha0s.io/cha0s/flecks/commits/9a5fb07d81fea6b5bb915ef2efe5973c186392aa))
* paths got broken somehow ([c7bbc48](https://git.hq.cha0s.io/cha0s/flecks/commits/c7bbc48d3a4c4db2b57c1002b73f4baac0b80172))
### Features
* electron ([67723d1](https://git.hq.cha0s.io/cha0s/flecks/commits/67723d1d356af94a1bbbc38c734722d4409ba057))
* electron with start-server-webpack-plugin ([1ade829](https://git.hq.cha0s.io/cha0s/flecks/commits/1ade8294a1d825cfa4361daa245c50ff05f6fa79))
* **electron:** devtools ([10d59e1](https://git.hq.cha0s.io/cha0s/flecks/commits/10d59e16edc6e8828c019fa728f19546a4c55042))
* reopen closed ([11c61b3](https://git.hq.cha0s.io/cha0s/flecks/commits/11c61b3d7284cd8403660e71c314aba276244d8b))
* webpack 5 support ([288b368](https://git.hq.cha0s.io/cha0s/flecks/commits/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))

View File

@ -1,6 +1,14 @@
{ {
"name": "@flecks/electron", "name": "@flecks/electron",
"version": "1.4.1", "repository": {
"type": "git",
"url": "https://github.com/cha0s/flecks.git",
"directory": "packages/electron"
},
"publishConfig": {
"access": "public"
},
"version": "2.0.3",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
"clean": "flecks clean", "clean": "flecks clean",
@ -16,12 +24,11 @@
"test" "test"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"@neutrinojs/banner": "^9.5.0",
"electron": "^18.0.1", "electron": "^18.0.1",
"electron-devtools-installer": "^3.2.0" "electron-devtools-installer": "^3.2.0"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -1,9 +1,8 @@
import {join} from 'path'; import {join} from 'path';
import banner from '@neutrinojs/banner'; import {banner} from '@flecks/core/server';
const { const {
FLECKS_CORE_ROOT = process.cwd(),
NODE_ENV, NODE_ENV,
} = process.env; } = process.env;
@ -19,12 +18,13 @@ async function createWindow(flecks) {
export const hooks = { export const hooks = {
'@flecks/core.build': (target, config) => { '@flecks/core.build': (target, config) => {
if ('server' === target) { if ('server' === target) {
config.use.push(banner({ config.plugins.push(
banner({
// Bootstrap our `require()` magic.
banner: "require('module').Module._initPaths();", banner: "require('module').Module._initPaths();",
include: 'index.js', include: 'index.js',
pluginId: 'initPaths', }),
raw: true, );
}));
} }
}, },
'@flecks/core.config': () => ({ '@flecks/core.config': () => ({
@ -55,16 +55,19 @@ export const hooks = {
*/ */
url: undefined, url: undefined,
}), }),
'@flecks/core.webpack': (target, config) => { '@flecks/core.build.alter': (configs) => {
const {server: config} = configs;
if (config) {
const plugin = config.plugins.find(({pluginName}) => pluginName === 'StartServerPlugin'); const plugin = config.plugins.find(({pluginName}) => pluginName === 'StartServerPlugin');
// Extremely hackish, c'est la vie. // Extremely hackish, c'est la vie.
if (plugin) { if (plugin) {
const {exec} = plugin.options; const {exec} = plugin.options;
plugin.options.exec = (compilation) => { plugin.options.exec = (compilation) => {
plugin.options.args = [compilation.assets[exec].existsAt]; plugin.options.args = [join(config.output.path, compilation.getPath(exec))];
return join(FLECKS_CORE_ROOT, 'node_modules', '.bin', 'electron'); return join('..', 'node_modules', '.bin', 'electron');
}; };
} }
}
}, },
'@flecks/electron/server.initialize': async (electron, flecks) => { '@flecks/electron/server.initialize': async (electron, flecks) => {
electron.app.on('window-all-closed', () => { electron.app.on('window-all-closed', () => {

View File

@ -3,6 +3,50 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/fleck
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/fleck
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Bug Fixes
* mocha error propagation ([1f11aac](https://github.com/cha0s/flecks/commit/1f11aac027e0699b821c2bc9f31bdfe3fd61a2d0))
* test fails -> nonzero process code ([1f01189](https://github.com/cha0s/flecks/commit/1f0118914393d8b16913aad25eef81aaadac4e68))
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/fleck **Note:** Version bump only for package @flecks/fleck

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"author": "cha0s", "author": "cha0s",
"license": "MIT", "license": "MIT",
"bin": { "bin": {
@ -22,8 +22,8 @@
}, },
"files": [ "files": [
"build", "build",
"server/build/fleck.neutrinorc.js", "server/build/fleck.webpack.config.js",
"server/build/fleck.neutrinorc.js.map", "server/build/fleck.webpack.config.js.map",
"server.js", "server.js",
"server.js.map", "server.js.map",
"src", "src",
@ -31,7 +31,7 @@
"test.js.map" "test.js.map"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"babel-merge": "^3.0.0", "babel-merge": "^3.0.0",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"clear-module": "^4.1.2", "clear-module": "^4.1.2",

View File

@ -1,42 +0,0 @@
const {join} = require('path');
const {D} = require('@flecks/core');
const {fleck} = require('@flecks/core/server');
const babelmerge = require('babel-merge');
const glob = require('glob');
const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
const debug = D('@flecks/fleck/fleck.neutrino.js');
const debugSilly = debug.extend('silly');
const config = require('../../../../core/src/bootstrap/fleck.neutrinorc');
module.exports = async (flecks) => {
// Compile.
const rcBabel = flecks.babel();
debugSilly('.flecksrc: babel: %j', rcBabel);
config.use.push(fleck({
babel: babelmerge.all([
{configFile: flecks.buildConfig('babel.config.js')},
...rcBabel.map(([, babel]) => babel),
]),
}));
config.use.push(({config}) => {
config.stats(flecks.get('@flecks/fleck/server.stats'));
});
config.use.push(({config}) => {
// Test entrypoint.
const testPaths = glob.sync(join(FLECKS_CORE_ROOT, 'test/*.js'));
for (let i = 0; i < flecks.platforms.length; ++i) {
testPaths.push(...glob.sync(join(FLECKS_CORE_ROOT, `test/platforms/${flecks.platforms[i]}/*.js`)));
}
if (testPaths.length > 0) {
const testEntry = config.entry('test').clear();
testPaths.forEach((path) => testEntry.add(path));
}
});
return config;
};

View File

@ -0,0 +1,7 @@
const flecksConfigFn = require('@flecks/core/server/build/fleck.webpack.config');
module.exports = async (env, argv, flecks) => {
const config = await flecksConfigFn(env, argv, flecks);
config.stats = flecks.get('@flecks/fleck/server.stats');
return config;
};

View File

@ -50,7 +50,9 @@ export default (program, flecks) => {
} }
catch (error) { catch (error) {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
await new Promise((resolve) => setTimeout(resolve, 50)); await new Promise((resolve) => {
setTimeout(resolve, 50);
});
} }
} }
const runMocha = async () => { const runMocha = async () => {
@ -87,7 +89,9 @@ export default (program, flecks) => {
} }
chokidar.watch(testLocation) chokidar.watch(testLocation)
.on('all', async () => { .on('all', async () => {
await new Promise((resolve) => setTimeout(resolve, 50)); await new Promise((resolve) => {
setTimeout(resolve, 50);
});
runMocha(); runMocha();
}); });
return new Promise(() => {}); return new Promise(() => {});

View File

@ -4,13 +4,11 @@ export const hooks = {
'@flecks/core.commands': commands, '@flecks/core.commands': commands,
'@flecks/core.config': () => ({ '@flecks/core.config': () => ({
/** /**
* Webpack stats configuration when building fleck target. * Webpack stats configuration.
*/ */
stats: { stats: {
children: false,
chunks: false,
colors: true, colors: true,
modules: false, errorDetails: true,
}, },
}), }),
'@flecks/core.targets': () => ['fleck'], '@flecks/core.targets': () => ['fleck'],

View File

@ -3,6 +3,44 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/governor
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/governor
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/governor **Note:** Version bump only for package @flecks/governor

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
@ -26,12 +26,12 @@
"src" "src"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"@flecks/db": "^1.4.1", "@flecks/db": "^2.0.3",
"rate-limiter-flexible": "^2.1.13", "rate-limiter-flexible": "^2.1.13",
"redis": "^3.1.2" "redis": "^3.1.2"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -3,6 +3,51 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/react
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/react
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Bug Fixes
* avoid FOUC on dev ([18e2bb9](https://github.com/cha0s/flecks/commit/18e2bb9446b2ead51800f2dd2d094cbe8c6282f8))
### Features
* "wtf, you can't just take @babel/register, give it an actual API, and make it work simultaneously across multiple roots" ([82e22c3](https://github.com/cha0s/flecks/commit/82e22c3eef69f13b6b8645667d3362d49d3b3e6b))
* **react:** configure in web's absence ([754646d](https://github.com/cha0s/flecks/commit/754646d4a1df63de44f91e5a3184ebd9c75afd95))
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/react **Note:** Version bump only for package @flecks/react

View File

@ -1,5 +0,0 @@
const config = require('@flecks/core/server/build/.eslint.defaults.js');
config.globals.window = true;
module.exports = config;

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
@ -38,25 +38,23 @@
"router/server.js.map", "router/server.js.map",
"server.js", "server.js",
"server.js.map", "server.js.map",
"src", "src"
"style-loader.js",
"style-loader.js.map"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@babel/preset-react": "^7.23.3",
"@flecks/web": "^1.4.1", "@flecks/core": "^2.0.3",
"@hot-loader/react-dom": "^17.0.1", "@flecks/web": "^2.0.3",
"@neutrinojs/react": "^9.4.0", "@hot-loader/react-dom": "^17.0.2",
"babel-merge": "^3.0.0", "babel-merge": "^3.0.0",
"classnames": "^2.3.1", "classnames": "^2.3.1",
"history": "^5.3.0", "history": "^5.3.0",
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"react": "^17.0.1", "react": "^17.0.1",
"react-hot-loader": "^4.13.0", "react-hot-loader": "^4.13.1",
"react-router-dom": "^6.2.1", "react-router-dom": "6.20.0",
"redux-first-history": "^5.0.8" "redux-first-history": "5.1.1"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -3,22 +3,22 @@ import {augmentBuild} from '@flecks/web/server';
import ssr from './ssr'; import ssr from './ssr';
export const hooks = { export const hooks = {
'@flecks/core.build': (target, config, flecks) => { /* eslint-disable no-param-reassign */
// Resolution. '@flecks/core.build': (target, config, env, argv, flecks) => {
config.use.push(({config}) => { const isProduction = 'production' === argv.mode;
config.resolve.alias config.resolve.alias['react-native'] = 'react-native-web';
.set('react-native', 'react-native-web'); config.resolve.alias['react-hot-loader'] = isProduction
config.resolve.extensions ? 'react-hot-loader/dist/react-hot-loader.production'
.prepend('.web.js') : 'react-hot-loader/dist/react-hot-loader.development';
.prepend('.web.jsx'); config.resolve.extensions.unshift(...['.web.js', '.web.jsx']);
});
// Augment the build on behalf of a missing `@flecks/web`. // Augment the build on behalf of a missing `@flecks/web`.
if (!flecks.fleck('@flecks/web/server')) { if (!flecks.fleck('@flecks/web/server')) {
flecks.registerBuildConfig('postcss.config.js', {fleck: '@flecks/web/server'}); flecks.registerBuildConfig('postcss.config.js', {fleck: '@flecks/web/server'});
flecks.registerResolver('@flecks/web'); flecks.registerResolver('@flecks/web');
augmentBuild(target, config, flecks); augmentBuild(target, config, env, argv, flecks);
} }
}, },
/* eslint-enable no-param-reassign */
'@flecks/web/server.stream.html': (stream, req, flecks) => ( '@flecks/web/server.stream.html': (stream, req, flecks) => (
flecks.get('@flecks/react.ssr') ? ssr(stream, req, flecks) : stream flecks.get('@flecks/react.ssr') ? ssr(stream, req, flecks) : stream
), ),

View File

@ -22,9 +22,15 @@ class Ssr extends Transform {
const string = chunk const string = chunk
.toString('utf8'); .toString('utf8');
if (-1 !== string.indexOf('<div id="root"></div>')) { if (-1 !== string.indexOf('<div id="root"></div>')) {
const output = ReactDOMServer.renderToString( let output;
try {
output = ReactDOMServer.renderToString(
React.createElement(await root(this.flecks, this.req)), React.createElement(await root(this.flecks, this.req)),
); );
}
catch (e) {
output = '';
}
this.push( this.push(
string.replace( string.replace(
'<div id="root"></div>', '<div id="root"></div>',

View File

@ -3,6 +3,44 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/redis
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/redis
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/redis **Note:** Version bump only for package @flecks/redis

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
"clean": "flecks clean", "clean": "flecks clean",
@ -25,13 +25,13 @@
"src" "src"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"@socket.io/redis-adapter": "7.1.0", "@socket.io/redis-adapter": "7.1.0",
"connect-redis": "^5.0.0", "connect-redis": "^5.0.0",
"express-session": "^1.17.1", "express-session": "^1.17.1",
"redis": "4.0.3" "redis": "4.0.3"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -3,6 +3,49 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/redux
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/redux
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Bug Fixes
* async for parity ([780fa43](https://github.com/cha0s/flecks/commit/780fa433e156fbc7adad0f97aaebd3c821f40dee))
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/redux **Note:** Version bump only for package @flecks/redux

View File

@ -1,5 +0,0 @@
const config = require('@flecks/core/server/build/.eslint.defaults.js');
config.globals.window = true;
module.exports = config;

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
@ -28,7 +28,7 @@
"src" "src"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"@hot-loader/react-dom": "^17.0.1", "@hot-loader/react-dom": "^17.0.1",
"@reduxjs/toolkit": "^1.5.0", "@reduxjs/toolkit": "^1.5.0",
"debug": "^4.3.3", "debug": "^4.3.3",
@ -37,6 +37,6 @@
"reduce-reducers": "^1.0.4" "reduce-reducers": "^1.0.4"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -3,6 +3,44 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/repl
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/repl
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/repl **Note:** Version bump only for package @flecks/repl

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
"clean": "flecks clean", "clean": "flecks clean",
@ -23,11 +23,11 @@
"src" "src"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"command-exists": "^1.2.9", "command-exists": "^1.2.9",
"debug": "4.3.1" "debug": "4.3.1"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -62,7 +62,9 @@ export async function createReplServer(flecks) {
} }
const socket = join(tmpdir(), 'flecks', id, 'repl', `${id}-${Date.now()}.sock`); const socket = join(tmpdir(), 'flecks', id, 'repl', `${id}-${Date.now()}.sock`);
flecks.set('$flecks/repl.socket', socket); flecks.set('$flecks/repl.socket', socket);
await new Promise((resolve) => netServer.listen(socket, resolve)); await new Promise((resolve) => {
netServer.listen(socket, resolve);
});
debug('listening @ %s', socket); debug('listening @ %s', socket);
} }

View File

@ -3,6 +3,50 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/server
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/server
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Bug Fixes
* complex aliasing ([4ba2b51](https://github.com/cha0s/flecks/commit/4ba2b5113657f4426d8e976fe9a77d797378475a))
### Features
* awesomerific module resolution ([60c844d](https://github.com/cha0s/flecks/commit/60c844d58b294df0d9cf0be741266fdd8dd53a33))
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/server **Note:** Version bump only for package @flecks/server

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"main": "index.js", "main": "index.js",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
@ -26,23 +26,17 @@
"index.js.map", "index.js.map",
"runtime.js", "runtime.js",
"runtime.js.map", "runtime.js.map",
"server/build/server.neutrinorc.js", "server/build/server.webpack.config.js",
"server/build/server.neutrinorc.js.map", "server/build/server.webpack.config.js.map",
"server.js", "server.js",
"server.js.map", "server.js.map",
"src" "src"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"@neutrinojs/banner": "^9.5.0", "debug": "^4.3.3"
"@neutrinojs/clean": "^9.5.0",
"@neutrinojs/start-server": "^9.5.0",
"debug": "^4.3.3",
"loader-utils": "^1.4.0",
"source-map-loader": "^1.1.3",
"webpack-node-externals": "2.5.2"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -13,12 +13,11 @@ export const hooks = {
*/ */
start: true, start: true,
/** /**
* Webpack stats configuration when building server target. * Webpack stats configuration.
*/ */
stats: { stats: {
chunks: false,
colors: true, colors: true,
modules: false, errorDetails: true,
}, },
}), }),
}; };

View File

@ -1,6 +1,4 @@
const {getOptions} = require('loader-utils');
module.exports = function FlecksRuntime() { module.exports = function FlecksRuntime() {
const {source} = getOptions(this); const {source} = this.getOptions();
return source; return source;
}; };

View File

@ -1,12 +1,10 @@
const {realpath} = require('fs/promises'); const {realpath} = require('fs/promises');
const {join} = require('path'); const {join} = require('path');
const {require: R} = require('@flecks/core/server'); const {externals, require: R} = require('@flecks/core/server');
module.exports = async (flecks) => { module.exports = async (config, env, argv, flecks) => {
const runtime = await realpath(R.resolve(join(flecks.resolve('@flecks/server'), 'runtime'))); const runtime = await realpath(R.resolve(join(flecks.resolve('@flecks/server'), 'runtime')));
return (neutrino) => {
const {config, options} = neutrino;
const {resolver} = flecks; const {resolver} = flecks;
// Inject flecks configuration. // Inject flecks configuration.
const paths = Object.keys(resolver); const paths = Object.keys(resolver);
@ -29,7 +27,7 @@ module.exports = async (flecks) => {
source.push(' module.hot.addStatusHandler((status) => {'); source.push(' module.hot.addStatusHandler((status) => {');
source.push(' if ("idle" === status) {'); source.push(' if ("idle" === status) {');
source.push(' require("glob")('); source.push(' require("glob")(');
source.push(` join('${options.output}', \`*\${previousHash}.hot-update.*\`),`); source.push(` join('${config.output.path}', \`*\${previousHash}.hot-update.*\`),`);
source.push(' async (error, disposing) => {'); source.push(' async (error, disposing) => {');
source.push(' if (error) {'); source.push(' if (error) {');
source.push(' throw error;'); source.push(' throw error;');
@ -50,32 +48,34 @@ module.exports = async (flecks) => {
}); });
source.push('}'); source.push('}');
// Create runtime. // Create runtime.
config.module config.module.rules.push(
.rule(runtime) {
.test(runtime) test: runtime,
.use('runtime') use: [
.loader(runtime) {
.options({ loader: runtime,
options: {
source: source.join('\n'), source: source.join('\n'),
}); },
},
],
},
);
const allowlist = [ const allowlist = [
'@flecks/server/entry', '@flecks/server/entry',
'@flecks/server/runtime', '@flecks/server/runtime',
/^@babel\/runtime\/helpers\/esm/, /^@babel\/runtime\/helpers\/esm/,
]; ];
config.resolve.alias config.resolve.alias['@flecks/server/runtime$'] = runtime;
.set('@flecks/server/runtime$', runtime);
const nodeExternalsConfig = { const nodeExternalsConfig = {
additionalModuleDirs: [], additionalModuleDirs: [],
allowlist, allowlist,
}; };
flecks.runtimeCompiler(flecks.resolver, 'server', neutrino, nodeExternalsConfig); flecks.runtimeCompiler(flecks.resolver, 'server', config, nodeExternalsConfig);
// Rewrite to signals for HMR. // Rewrite to signals for HMR.
if ('production' !== config.get('mode')) { if ('production' !== argv.mode) {
allowlist.push(/^webpack/); allowlist.push(/^webpack/);
} }
// Externalize the rest. // Externalize the rest.
const nodeExternals = R('webpack-node-externals'); config.externals = externals(nodeExternalsConfig);
config.externals(nodeExternals(nodeExternalsConfig));
};
}; };

View File

@ -1,102 +0,0 @@
const {join} = require('path');
const {require: R} = require('@flecks/core/server');
const banner = require('@neutrinojs/banner');
const clean = require('@neutrinojs/clean');
const runtime = require('./runtime');
const startServer = require('./start');
const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
module.exports = async (flecks) => {
const {
hot,
nodeArgs,
start: isStarting,
} = flecks.get('@flecks/server');
const server = (neutrino) => {
const {config, options} = neutrino;
const isProduction = 'production' === config.get('mode');
neutrino.use(banner());
neutrino.use(clean({cleanStaleWebpackAssets: false}));
// Entrypoints.
config.context(options.root);
const entries = config.entry('index');
if (!isProduction && hot) {
config
.plugin('hot')
.use(R.resolve('webpack/lib/HotModuleReplacementPlugin'));
entries.add('webpack/hot/signal');
}
entries.add('@flecks/server/entry');
// Fold in existing source maps.
config.module
.rule('maps')
.test(/\.js$/)
.enforce('pre')
.use('source-map-loader')
.loader('source-map-loader');
// Resolution.
config.resolve.extensions
.merge([
'.wasm',
...options.extensions.map((ext) => `.${ext}`),
'.json',
]);
// Reporting.
config.stats({
...flecks.get('@flecks/server.stats'),
warningsFilter: [
/Failed to parse source map/,
],
});
// Outputs.
config.output
.path(options.output)
.libraryTarget('commonjs2');
config.node
.set('__dirname', false)
.set('__filename', false);
config
.devtool('source-map')
.target('node');
};
// Augment the application-starting configuration.
const start = (neutrino) => {
if (isStarting) {
neutrino.use(startServer({
exec: 'index.js',
// Bail hard on unhandled rejections and report.
nodeArgs: [...nodeArgs, '--unhandled-rejections=strict', '--trace-uncaught'],
// HMR.
signal: !!hot,
}));
}
};
const config = {
options: {
output: 'dist',
root: FLECKS_CORE_ROOT,
},
use: [
server,
start,
],
};
// Build the server runtime.
config.use.push(await runtime(flecks));
// Give the resolver a helping hand.
config.use.push(({config}) => {
config.resolve.modules.merge([join(FLECKS_CORE_ROOT, 'node_modules')]);
});
return config;
};

View File

@ -0,0 +1,58 @@
const {
banner,
defaultConfig,
webpack,
} = require('@flecks/core/server');
const runtime = require('./runtime');
const startServer = require('./start');
module.exports = async (env, argv, flecks) => {
const {
hot,
nodeArgs,
start: isStarting,
} = flecks.get('@flecks/server');
const config = defaultConfig(flecks, {
node: {
__dirname: false,
__filename: false,
},
output: {
libraryTarget: 'commonjs2',
},
plugins: [
banner({banner: "require('source-map-support').install();"}),
],
stats: {
...flecks.get('@flecks/server.stats'),
warningsFilter: [
/Failed to parse source map/,
],
},
target: 'node',
});
const isProduction = 'production' === argv.mode;
// Entrypoints.
config.entry.index = [];
if (!isProduction && hot) {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.entry.index.push('webpack/hot/signal');
}
config.entry.index.push('@flecks/server/entry');
// Augment the application-starting configuration.
if (isStarting) {
config.plugins.push(
startServer({
exec: 'index.js',
// Bail hard on unhandled rejections and report.
nodeArgs: [...nodeArgs, '--unhandled-rejections=strict', '--trace-uncaught'],
// HMR.
signal: !!hot,
}),
);
}
// Build the server runtime.
await runtime(config, env, argv, flecks);
return config;
};

View File

@ -1,4 +1,5 @@
const cluster = require('cluster'); const cluster = require('cluster');
const {join} = require('path');
class StartServerPlugin { class StartServerPlugin {
@ -30,10 +31,10 @@ class StartServerPlugin {
} }
let entryPoint; let entryPoint;
if (!exec) { if (!exec) {
entryPoint = compilation.assets[Object.keys(compilation.assets)[0]].existsAt; entryPoint = compilation.getPath(Object.keys(compilation.assets)[0]);
} }
else if (compilation.assets[exec]) { else if (compilation.assets[exec]) {
entryPoint = compilation.assets[exec].existsAt; entryPoint = compilation.getPath(exec);
} }
else if ('string' === typeof exec) { else if ('string' === typeof exec) {
entryPoint = exec; entryPoint = exec;
@ -41,10 +42,7 @@ class StartServerPlugin {
else { else {
entryPoint = exec(compilation); entryPoint = exec(compilation);
} }
this.startServer( this.startServer(join(compiler.options.output.path, entryPoint), callback);
entryPoint,
callback,
);
}); });
compiler.hooks.shouldEmit.tap(pluginName, (compilation) => { compiler.hooks.shouldEmit.tap(pluginName, (compilation) => {
const entryPoints = Object.keys(compilation.assets); const entryPoints = Object.keys(compilation.assets);
@ -84,17 +82,6 @@ class StartServerPlugin {
} }
module.exports = ({ module.exports = (pluginOptions = {}) => (
nodeArgs = [], new StartServerPlugin(pluginOptions)
pluginId = 'start-server',
...pluginOptions
} = {}) => (
({config, options}) => {
config
.plugin(pluginId)
.use(
StartServerPlugin,
[{...pluginOptions, nodeArgs: nodeArgs.concat(options.debug ? ['--inspect'] : [])}],
);
}
); );

View File

@ -3,6 +3,44 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/socket
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/socket
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Features
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/socket **Note:** Version bump only for package @flecks/socket

View File

@ -1,5 +0,0 @@
const config = require('@flecks/core/server/build/.eslint.defaults.js');
config.globals.window = true;
module.exports = config;

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
@ -28,8 +28,8 @@
"src" "src"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"@flecks/react": "^1.4.1", "@flecks/react": "^2.0.3",
"msgpack-lite": "^0.1.26", "msgpack-lite": "^0.1.26",
"proxy-addr": "^2.0.6", "proxy-addr": "^2.0.6",
"schemapack": "^1.4.2", "schemapack": "^1.4.2",
@ -37,6 +37,6 @@
"socket.io-client": "^4.1.2" "socket.io-client": "^4.1.2"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -5,7 +5,7 @@ import Refresh from './packet/refresh';
export {default as normalize} from './normalize'; export {default as normalize} from './normalize';
export * from './hooks'; export * from './hooks';
export {default as Packet, Packer, ValidationError} from './packet'; export {Packet, Packer, ValidationError} from './packet';
export const hooks = { export const hooks = {
'@flecks/core.starting': (flecks) => { '@flecks/core.starting': (flecks) => {

View File

@ -1,3 +1,3 @@
export {default as Packer} from './packer'; export {default as Packer} from './packer';
export {default} from './packet'; export {default as Packet} from './packet';
export {default as ValidationError} from './validation-error'; export {default as ValidationError} from './validation-error';

View File

@ -13,7 +13,9 @@ export default function createIntercom(sockets, transport) {
); );
}); });
responses.push( responses.push(
await new Promise((resolve) => sockets.localIntercom({payload, type}, resolve)), await new Promise((resolve) => {
sockets.localIntercom({payload, type}, resolve);
}),
); );
return responses; return responses;
}; };

View File

@ -3,6 +3,45 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/user
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/user
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Features
* UserRequired ([9b5f6f4](https://github.com/cha0s/flecks/commit/9b5f6f4818afaec76ee941c8d2c4795912234ee8))
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/user **Note:** Version bump only for package @flecks/user

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
@ -34,9 +34,9 @@
"src" "src"
], ],
"dependencies": { "dependencies": {
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"@flecks/react": "^1.4.1", "@flecks/react": "^2.0.3",
"@flecks/redux": "^1.4.1", "@flecks/redux": "^2.0.3",
"bcrypt": "^5.0.0", "bcrypt": "^5.0.0",
"express": "^4.17.1", "express": "^4.17.1",
"express-session": "1.17.1", "express-session": "1.17.1",
@ -45,6 +45,6 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-react": "^7.12.10", "@babel/preset-react": "^7.12.10",
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^2.0.3"
} }
} }

View File

@ -5,7 +5,9 @@ export default (flecks) => {
static respond(packet, {req}) { static respond(packet, {req}) {
req.logout(); req.logout();
return new Promise((r, e) => req.session.save((error) => (error ? e(error) : r()))); return new Promise((r, e) => {
req.session.save((error) => (error ? e(error) : r()));
});
} }
static validate(packet, {req}) { static validate(packet, {req}) {

View File

@ -3,6 +3,51 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.3](https://github.com/cha0s/flecks/compare/v2.0.2...v2.0.3) (2023-11-22)
### Bug Fixes
* electron ([81fc978](https://github.com/cha0s/flecks/commit/81fc978da2b8d32e303d165fe7c2f6071ac8e741))
## [2.0.2](https://github.com/cha0s/flecks/compare/v2.0.1...v2.0.2) (2023-11-22)
**Note:** Version bump only for package @flecks/web
## [2.0.1](https://github.com/cha0s/flecks/compare/v2.0.0...v2.0.1) (2023-11-22)
**Note:** Version bump only for package @flecks/web
# [2.0.0](https://github.com/cha0s/flecks/compare/v1.4.1...v2.0.0) (2023-11-22)
### Bug Fixes
* avoid FOUC on dev ([18e2bb9](https://github.com/cha0s/flecks/commit/18e2bb9446b2ead51800f2dd2d094cbe8c6282f8))
### Features
* html template specifier ([5791c7a](https://github.com/cha0s/flecks/commit/5791c7a89433f16c1efea045a00ab488975c6dab))
* per-entry styles ([d43316a](https://github.com/cha0s/flecks/commit/d43316a43635ea19338a6a1ce917f9b2d308c977))
* webpack 5 support ([288b368](https://github.com/cha0s/flecks/commit/288b368b9ff96be5ccb58bd811838a4a4bb6c48c))
## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19) ## [1.4.1](https://github.com/cha0s/flecks/compare/v1.4.0...v1.4.1) (2022-03-19)
**Note:** Version bump only for package @flecks/web **Note:** Version bump only for package @flecks/web

View File

@ -1,5 +0,0 @@
const config = require('@flecks/core/server/build/.eslint.defaults.js');
config.globals.window = true;
module.exports = config;

View File

@ -1,46 +0,0 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const copy = require('@neutrinojs/copy');
const styleLoader = require('@neutrinojs/style-loader');
const nodeExternals = require('webpack-node-externals');
module.exports = async (flecks) => {
// eslint-disable-next-line import/no-extraneous-dependencies, global-require
const config = await require('@flecks/fleck/server/build/fleck.neutrinorc')(flecks);
config.use.push(({config}) => {
config.entryPoints.delete('server/build/entry');
config.entryPoints.delete('server/build/template');
config.entryPoints.delete('server/build/tests');
config.externals(nodeExternals({
allowlist: ['mocha/mocha.css'],
importType: 'umd',
}));
});
config.use.push(styleLoader({
extract: {
enabled: false,
},
style: {
injectType: 'lazyStyleTag',
},
}));
config.use.push(
copy({
copyUnmodified: true,
patterns: [
{
from: 'src/server/build/entry.js',
to: 'server/build/entry.js',
},
{
from: 'src/server/build/template.ejs',
to: 'server/build/template.ejs',
},
{
from: 'src/server/build/tests.js',
to: 'server/build/tests.js',
},
],
}),
);
return config;
};

View File

@ -0,0 +1,34 @@
const {copy, externals} = require('@flecks/core/server');
// eslint-disable-next-line import/no-extraneous-dependencies
const configFn = require('@flecks/fleck/server/build/fleck.webpack.config');
module.exports = async (env, argv, flecks) => {
// eslint-disable-next-line import/no-extraneous-dependencies, global-require
const config = await configFn(env, argv, flecks);
delete config.entry['server/build/entry'];
delete config.entry['server/build/template'];
delete config.entry['server/build/tests'];
config.externals = externals({
allowlist: ['mocha/mocha.css'],
importType: 'umd',
});
config.plugins.push(
copy({
patterns: [
{
from: 'src/server/build/entry.js',
to: 'server/build/entry.js',
},
{
from: 'src/server/build/template.ejs',
to: 'server/build/template.ejs',
},
{
from: 'src/server/build/tests.js',
to: 'server/build/tests.js',
},
],
}),
);
return config;
};

View File

@ -8,7 +8,7 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.4.1", "version": "2.0.3",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "flecks build", "build": "flecks build",
@ -32,10 +32,10 @@
"server/build/template.ejs", "server/build/template.ejs",
"server/build/tests.js", "server/build/tests.js",
"server/build/tests.js.map", "server/build/tests.js.map",
"server/build/web.neutrinorc.js", "server/build/web.webpack.config.js",
"server/build/web.neutrinorc.js.map", "server/build/web.webpack.config.js.map",
"server/build/web-vendor.neutrinorc.js", "server/build/web-vendor.webpack.config.js",
"server/build/web-vendor.neutrinorc.js.map", "server/build/web-vendor.webpack.config.js.map",
"src", "src",
"tests.js", "tests.js",
"tests.js.map" "tests.js.map"
@ -43,35 +43,33 @@
"dependencies": { "dependencies": {
"@babel/parser": "^7.17.0", "@babel/parser": "^7.17.0",
"@babel/types": "^7.17.0", "@babel/types": "^7.17.0",
"@flecks/core": "^1.4.1", "@flecks/core": "^2.0.3",
"@neutrinojs/dev-server": "^9.5.0", "@webpack-cli/serve": "^2.0.5",
"@neutrinojs/font-loader": "^9.5.0", "add-asset-html-webpack-plugin": "^6.0.0",
"@neutrinojs/html-loader": "^9.5.0",
"@neutrinojs/html-template": "^9.5.0",
"@neutrinojs/image-loader": "^9.5.0",
"@neutrinojs/style-loader": "^9.5.0",
"add-asset-html-webpack-plugin": "^5.0.1",
"autoprefixer": "^9.8.6", "autoprefixer": "^9.8.6",
"before-build-webpack": "^0.2.12", "before-build-webpack": "^0.2.13",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"clean-webpack-plugin": "4.0.0",
"compression": "^1.7.4", "compression": "^1.7.4",
"css-loader": "^6.8.1",
"express": "^4.17.1", "express": "^4.17.1",
"glob": "^7.2.0", "glob": "^7.2.0",
"html-webpack-plugin": "^4.5.0", "html-loader": "^4.2.0",
"html-webpack-plugin": "^5.5.3",
"http-proxy": "^1.17.0", "http-proxy": "^1.17.0",
"loader-utils": "^1.4.0",
"lodash.flatten": "^4.4.0", "lodash.flatten": "^4.4.0",
"mini-css-extract-plugin": "^2.7.6",
"mocha": "^8.3.2", "mocha": "^8.3.2",
"postcss-loader": "4.2.0", "postcss-loader": "4.2.0",
"react-dev-utils": "12.0.0", "react-dev-utils": "12.0.0",
"sass": "^1.49.9", "sass": "^1.49.9",
"sass-loader": "10.2.0", "sass-loader": "10.2.0",
"source-map-loader": "^1.1.3", "stream-browserify": "^3.0.0",
"webpack": "^4", "style-loader": "^3.3.3",
"webpack-dev-server": "^3.11.0", "webpack-dev-server": "^4.15.1"
"webpack-node-externals": "2.5.2"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1", "@flecks/fleck": "^2.0.3"
"@neutrinojs/copy": "^9.4.0"
} }
} }

View File

@ -1,6 +1,4 @@
const {getOptions} = require('loader-utils');
module.exports = function FlecksRuntime() { module.exports = function FlecksRuntime() {
const {source} = getOptions(this); const {source} = this.getOptions();
return source; return source;
}; };

View File

@ -1,55 +1,92 @@
import fontLoader from '@neutrinojs/font-loader'; import {regexFromExtensions} from '@flecks/core/server';
import imageLoader from '@neutrinojs/image-loader'; import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import styleLoader from '@neutrinojs/style-loader';
const augmentBuild = (target, config, flecks) => { const augmentBuild = (target, config, env, argv, flecks) => {
config.use.push((neutrino) => { const isProduction = 'production' === argv.mode;
const isProduction = 'production' === neutrino.config.get('mode'); let finalLoader;
const extract = {}; switch (target) {
const style = {}; case 'fleck': {
if ('server' === target) { finalLoader = {loader: MiniCssExtractPlugin.loader};
extract.enabled = false; config.plugins.push(new MiniCssExtractPlugin({filename: '[name].css'}));
style.injectType = 'lazyStyleTag'; break;
} }
if ('web' === target) { case 'server': {
extract.enabled = isProduction; finalLoader = {loader: 'style-loader', options: {injectType: 'lazyStyleTag'}};
style.injectType = 'styleTag'; break;
} }
if ('fleck' === target) { case 'web': {
extract.enabled = true; if (isProduction) {
extract.plugin = { finalLoader = {loader: MiniCssExtractPlugin.loader};
filename: '[name].css', config.plugins.push(new MiniCssExtractPlugin());
};
} }
neutrino.use( else {
styleLoader({ finalLoader = {loader: 'style-loader', options: {injectType: 'styleTag'}};
extract, }
break;
}
default: break;
}
const buildOneOf = (test, loaders, cssOptions = {}) => ({
test,
use: [
finalLoader,
{
loader: 'css-loader',
options: {
...cssOptions,
importLoaders: loaders.length,
},
},
...loaders,
'source-map-loader',
],
});
const stylesWithModulesRule = (extensions, loaders) => ({
oneOf: [
// `.module.*` must match first.
buildOneOf(
regexFromExtensions(extensions.map((ext) => `module${ext}`)),
loaders,
{
modules: { modules: {
localIdentName: isProduction ? '[hash]' : '[path][name]__[local]', localIdentName: isProduction ? '[hash]' : '[path][name]__[local]',
}, },
style, },
test: /\.(c|s[ac])ss$/, ),
modulesTest: /\.module\.(c|s[ac])ss$/, buildOneOf(
loaders: [ regexFromExtensions(extensions),
{ loaders,
),
],
});
const postcss = {
loader: 'postcss-loader', loader: 'postcss-loader',
useId: 'postcss',
options: { options: {
postcssOptions: { postcssOptions: {
config: flecks.buildConfig('postcss.config.js'), config: flecks.buildConfig('postcss.config.js'),
}, },
}, },
};
// Originally separated because Sass can't handle incoming source maps, but probably more
// performant with 3rd-party CSS anyway.
config.module.rules.push(stylesWithModulesRule(['.css'], [postcss]));
config.module.rules.push(stylesWithModulesRule(['.sass', '.scss'], [postcss, 'sass-loader']));
// Fonts.
config.module.rules.push({
generator: {
filename: 'assets/[hash][ext][query]',
}, },
{ test: /\.(eot|ttf|woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'sass-loader', type: 'asset',
useId: 'sass', });
}, // Images.
], config.module.rules.push({
}), generator: {
); filename: 'assets/[hash][ext][query]',
},
test: /\.(ico|png|jpg|jpeg|gif|svg|webp)(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset',
}); });
config.use.push(fontLoader());
config.use.push(imageLoader());
}; };
export default augmentBuild; export default augmentBuild;

View File

@ -1,27 +0,0 @@
const devServer = require('@neutrinojs/dev-server');
module.exports = (flecks) => (neutrino) => {
const {
devHost,
devPort,
devPublic,
devStats,
port,
public: $$public,
} = flecks.get('@flecks/web/server');
neutrino.use(devServer({
historyApiFallback: {
disableDotRule: true,
},
hot: false,
host: devHost,
port: devPort || (port + 1),
public: devPublic || $$public,
stats: {
...devStats,
warningsFilter: [
/Failed to parse source map/,
],
},
}));
};

Some files were not shown because too many files have changed in this diff Show More