switch build system to esbuild
This commit is contained in:
parent
c5899c78b0
commit
1d6a4249af
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"overrides": [
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
}
|
||||||
|
}
|
34
.eslintrc.js
34
.eslintrc.js
|
@ -1,34 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
"env": {
|
|
||||||
"browser": true,
|
|
||||||
"es6": true,
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"extends": "eslint:recommended",
|
|
||||||
"globals": {
|
|
||||||
"Atomics": "readonly",
|
|
||||||
"SharedArrayBuffer": "readonly"
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2017,
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"no-console": [
|
|
||||||
"warn"
|
|
||||||
],
|
|
||||||
"indent": [
|
|
||||||
"error",
|
|
||||||
4,
|
|
||||||
{"SwitchCase": 1}
|
|
||||||
],
|
|
||||||
"quotes": [
|
|
||||||
"error",
|
|
||||||
"single"
|
|
||||||
],
|
|
||||||
"semi": [
|
|
||||||
"error",
|
|
||||||
"always"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
function Anchor(opts = {}) {
|
|
||||||
const NAMESPACE = `_${Math.random().toString(36).slice(-6)}_`.toUpperCase();
|
|
||||||
|
|
||||||
const GLOBAL = opts.global || {};
|
|
||||||
|
|
||||||
const register = function register(key, value) {
|
|
||||||
if (GLOBAL[NAMESPACE] && !GLOBAL[NAMESPACE][key]) {
|
|
||||||
return GLOBAL[NAMESPACE][key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}.bind(GLOBAL[NAMESPACE]);
|
|
||||||
|
|
||||||
function build(opts, register) {
|
|
||||||
if (GLOBAL[NAMESPACE]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLOBAL[NAMESPACE] = opts.register || {};
|
|
||||||
GLOBAL[NAMESPACE]['register'] = register;
|
|
||||||
|
|
||||||
(opts.mixins || []).forEach((mixin) => Object.assign(GLOBAL[NAMESPACE], mixin));
|
|
||||||
|
|
||||||
return GLOBAL[NAMESPACE];
|
|
||||||
}
|
|
||||||
return build(opts || {}, register);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Anchor;
|
|
|
@ -1 +1,2 @@
|
||||||
function Anchor(n={}){const r=`_${Math.random().toString(36).slice(-6)}_`.toUpperCase(),t=n.global||{};return function(n,e){return!t[r]&&(t[r]=n.register||{},t[r].register=e,(n.mixins||[]).forEach(n=>Object.assign(t[r],n)),t[r])}(n||{},function(n,e){return!(!t[r]||t[r][n])&&(t[r][n]=e)}.bind(t[r]))}export default Anchor;
|
function u(s={}){const r=`_${Math.random().toString(36).slice(-6)}_`.toUpperCase(),e=s.global||{},o=function(n,i){return e[r]&&!e[r][n]?e[r][n]=i:!1}.bind(e[r]);function c(t,n){return e[r]?!1:(e[r]=t.register||{},e[r].register=n,(t.mixins||[]).forEach(i=>Object.assign(e[r],i)),e[r])}return c(s||{},o)}export default u;
|
||||||
|
//# sourceMappingURL=anchor.min.js.map
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"sources": ["../src/index.js"],
|
||||||
|
"sourcesContent": ["/**\n * Tiny global application registry\n */\nfunction Anchor(opts = {}) {\n // create a unique namespace to avoid collisions\n const NAMESPACE = `_${Math.random().toString(36).slice(-6)}_`.toUpperCase();\n\n // global object anchor\n const GLOBAL = opts.global || {};\n\n /**\n * Register\n *\n * Helper to extend functionality without overriding existing\n *\n * @param {String} key\n * @param {Any} value\n */\n const register = function register(key, value) {\n if (GLOBAL[NAMESPACE] && !GLOBAL[NAMESPACE][key]) {\n return GLOBAL[NAMESPACE][key] = value;\n }\n\n return false;\n }.bind(GLOBAL[NAMESPACE]);\n\n /**\n * Builds the Application Anchor\n *\n * @param {Object} fasten\n * @param {Array} mixins\n * @param {Boolean} debug\n */\n function build(opts, register) {\n if (GLOBAL[NAMESPACE]) {\n // already initialized\n return false;\n }\n\n // add to global instance\n GLOBAL[NAMESPACE] = opts.register || {};\n GLOBAL[NAMESPACE]['register'] = register;\n\n // merge with global instance\n (opts.mixins || []).forEach((mixin) => Object.assign(GLOBAL[NAMESPACE], mixin));\n\n return GLOBAL[NAMESPACE];\n }\n\n return build(opts || {}, register);\n}\n\nexport default Anchor;\n"],
|
||||||
|
"mappings": "AAGA,SAASA,EAAOC,EAAO,CAAC,EAAG,CAEvB,MAAMC,EAAY,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,YAAY,EAGpEC,EAASF,EAAK,QAAU,CAAC,EAUzBG,EAAW,SAAkBC,EAAKC,EAAO,CAC3C,OAAIH,EAAOD,CAAS,GAAK,CAACC,EAAOD,CAAS,EAAEG,CAAG,EACpCF,EAAOD,CAAS,EAAEG,CAAG,EAAIC,EAG7B,EACX,EAAE,KAAKH,EAAOD,CAAS,CAAC,EASxB,SAASK,EAAMN,EAAMG,EAAU,CAC3B,OAAID,EAAOD,CAAS,EAET,IAIXC,EAAOD,CAAS,EAAID,EAAK,UAAY,CAAC,EACtCE,EAAOD,CAAS,EAAE,SAAcE,GAG/BH,EAAK,QAAU,CAAC,GAAG,QAASO,GAAU,OAAO,OAAOL,EAAOD,CAAS,EAAGM,CAAK,CAAC,EAEvEL,EAAOD,CAAS,EAC3B,CAEA,OAAOK,EAAMN,GAAQ,CAAC,EAAGG,CAAQ,CACrC,CAEA,eAAeJ",
|
||||||
|
"names": ["Anchor", "opts", "NAMESPACE", "GLOBAL", "register", "key", "value", "build", "mixin"]
|
||||||
|
}
|
|
@ -1,37 +0,0 @@
|
||||||
(function (global, factory) {
|
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
||||||
typeof define === 'function' && define.amd ? define('umd', factory) :
|
|
||||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.umd = factory());
|
|
||||||
}(this, (function () { 'use strict';
|
|
||||||
|
|
||||||
function Anchor(opts = {}) {
|
|
||||||
const NAMESPACE = `_${Math.random().toString(36).slice(-6)}_`.toUpperCase();
|
|
||||||
|
|
||||||
const GLOBAL = opts.global || {};
|
|
||||||
|
|
||||||
const register = function register(key, value) {
|
|
||||||
if (GLOBAL[NAMESPACE] && !GLOBAL[NAMESPACE][key]) {
|
|
||||||
return GLOBAL[NAMESPACE][key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}.bind(GLOBAL[NAMESPACE]);
|
|
||||||
|
|
||||||
function build(opts, register) {
|
|
||||||
if (GLOBAL[NAMESPACE]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLOBAL[NAMESPACE] = opts.register || {};
|
|
||||||
GLOBAL[NAMESPACE]['register'] = register;
|
|
||||||
|
|
||||||
(opts.mixins || []).forEach((mixin) => Object.assign(GLOBAL[NAMESPACE], mixin));
|
|
||||||
|
|
||||||
return GLOBAL[NAMESPACE];
|
|
||||||
}
|
|
||||||
return build(opts || {}, register);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Anchor;
|
|
||||||
|
|
||||||
})));
|
|
|
@ -1 +0,0 @@
|
||||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define("umd",n):(e="undefined"!=typeof globalThis?globalThis:e||self).umd=n()}(this,function(){"use strict";return function(e={}){const n=`_${Math.random().toString(36).slice(-6)}_`.toUpperCase(),t=e.global||{};return function(e,i){return!t[n]&&(t[n]=e.register||{},t[n].register=i,(e.mixins||[]).forEach(e=>Object.assign(t[n],e)),t[n])}(e||{},function(e,i){return!(!t[n]||t[n][e])&&(t[n][e]=i)}.bind(t[n]))}});
|
|
25
gulpfile.js
25
gulpfile.js
|
@ -1,25 +0,0 @@
|
||||||
const gulp = require("gulp");
|
|
||||||
const minify = require("gulp-minify");
|
|
||||||
const strip = require("gulp-strip-comments");
|
|
||||||
const rollup = require("gulp-rollup-2").rollup;
|
|
||||||
|
|
||||||
gulp.task("default", function build() {
|
|
||||||
return gulp.src("./src/*.js")
|
|
||||||
.pipe(rollup({
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: "anchor.js",
|
|
||||||
name: "es",
|
|
||||||
format: "es"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: "anchor.umd.js",
|
|
||||||
name: "umd",
|
|
||||||
format: "umd"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}))
|
|
||||||
.pipe(strip({safe: true}))
|
|
||||||
.pipe(minify({ext: {min: ".min.js"}}))
|
|
||||||
.pipe(gulp.dest("dist"))
|
|
||||||
});
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Document</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="module">
|
||||||
|
import Anchor from './src/index.js';
|
||||||
|
|
||||||
|
|
||||||
|
let app = Anchor({
|
||||||
|
register: {
|
||||||
|
'version': '1.0.0'
|
||||||
|
},
|
||||||
|
global: window,
|
||||||
|
mixins: [console]
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('app', app);
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
|
@ -1,30 +1,26 @@
|
||||||
{
|
{
|
||||||
"name": "anchor",
|
"name": "anchor",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "tiny global application registry",
|
"description": "tiny global application registry",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
|
"type": "module",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npx gulp default",
|
"build": "npx esbuild src/index.js --minify --sourcemap --outfile=dist/anchor.min.js",
|
||||||
"test": "npm run build && npm run lint && deno run test/index.spec.js",
|
"test": "npm run build && npm run lint && deno run test/index.spec.js",
|
||||||
"lint": "npx eslint src/index.js"
|
"lint": "npx eslint src/index.js"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"utility",
|
"utility",
|
||||||
"micro-frontend",
|
"micro-frontend",
|
||||||
"spa"
|
"spa",
|
||||||
|
"registry"
|
||||||
],
|
],
|
||||||
"author": "Geoff Doty",
|
"author": "Geoff Doty",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^7.16.0",
|
"eslint": "^8.35.0"
|
||||||
"gulp": "^4.0.2",
|
|
||||||
"gulp-minify": "^3.1.0",
|
|
||||||
"gulp-rollup-2": "^1.2.1",
|
|
||||||
"gulp-strip-comments": "^2.5.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,9 @@ function Anchor(opts = {}) {
|
||||||
(opts.mixins || []).forEach((mixin) => Object.assign(GLOBAL[NAMESPACE], mixin));
|
(opts.mixins || []).forEach((mixin) => Object.assign(GLOBAL[NAMESPACE], mixin));
|
||||||
|
|
||||||
return GLOBAL[NAMESPACE];
|
return GLOBAL[NAMESPACE];
|
||||||
};
|
}
|
||||||
|
|
||||||
return build(opts || {}, register);
|
return build(opts || {}, register);
|
||||||
};
|
}
|
||||||
|
|
||||||
export default Anchor;
|
export default Anchor;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import test from "../node_modules/testit/dist/testit.js";
|
import test from "https://raw.githubusercontent.com/n2geoff/testit/master/dist/testit.min.js";
|
||||||
import Anchor from "../src/index.js";
|
import Anchor from "../src/index.js";
|
||||||
|
|
||||||
test.it({
|
test.it({
|
||||||
|
|
Loading…
Reference in New Issue