weboptimizer 2.0.1428 → 2.0.1435
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -10
- package/test/browser.d.ts +1 -0
- package/test/browser.js +37 -0
- package/test/configurator.d.ts +1 -0
- package/test/configurator.js +16 -0
- package/test/ejsLoader.d.ts +1 -0
- package/test/ejsLoader.js +53 -0
- package/test/helper.d.ts +1 -0
- package/test/helper.js +397 -0
- package/test/index.d.ts +1 -0
- package/test/index.js +44 -0
- package/test/stylelintConfigurator.d.ts +1 -0
- package/test/stylelintConfigurator.js +16 -0
- package/test/webpackConfigurator.d.ts +1 -0
- package/test/webpackConfigurator.js +43 -0
- package/browser.d.ts +0 -11
- package/configurator.d.ts +0 -26
- package/ejsLoader.d.ts +0 -35
- package/helper.d.ts +0 -284
- package/index.d.ts +0 -20
- package/jestEnvironmentBrowser.d.ts +0 -18
- package/stylelintConfigurator.d.ts +0 -2
- package/type.d.ts +0 -483
- package/webpackConfigurator.d.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weboptimizer",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1435",
|
|
4
4
|
"description": "A generic web optimizer, (module) bundler and development environment.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -56,9 +56,7 @@
|
|
|
56
56
|
"webpackConfigurator.d.ts",
|
|
57
57
|
"webpackConfigurator.js"
|
|
58
58
|
],
|
|
59
|
-
"bin":
|
|
60
|
-
"weboptimizer": "index.js"
|
|
61
|
-
},
|
|
59
|
+
"bin": "index.js",
|
|
62
60
|
"repository": {
|
|
63
61
|
"type": "git",
|
|
64
62
|
"url": "https://github.com/thaibault/weboptimizer.git"
|
|
@@ -71,10 +69,10 @@
|
|
|
71
69
|
"build:types": "tsc --declaration --emitDeclarationOnly",
|
|
72
70
|
"check": "yarn check:types; yarn lint",
|
|
73
71
|
"check:types": "tsc --noEmit",
|
|
74
|
-
"clear": "rimraf apiDocumentation plugins/*.d.ts plugins/*.js browser.d.ts configurator.d.ts ejsLoader.d.ts helper.d.ts index.d.ts jestEnvironmentBrowser.d.ts stylelintConfigurator.d.ts type.d.ts webpackConfigurator.d.ts *.js *.compiled.* *.compiled test/*.js test/*.compiled.* test/*.d.ts *.html *.log node_modules/weboptimizer .coverage .nyc_output || true",
|
|
72
|
+
"clear": "rimraf apiDocumentation 'plugins/*.d.ts' 'plugins/*.js' browser.d.ts configurator.d.ts ejsLoader.d.ts helper.d.ts index.d.ts jestEnvironmentBrowser.d.ts stylelintConfigurator.d.ts type.d.ts webpackConfigurator.d.ts '*.js' '*.compiled.*' '*.compiled' 'test/*.js' 'test/*.compiled.*' 'test/*.d.ts' '*.html' '*.log' node_modules/weboptimizer .coverage .nyc_output || true",
|
|
75
73
|
"document": "yarn build:plain && jsdoc --package ./package.json --readme ./readme.md --destination apiDocumentation *.js",
|
|
76
74
|
"lint": "yarn lint:base",
|
|
77
|
-
"lint:base": "eslint --ignore-pattern **/exclude/* --ignore-pattern '*.compiled.*' --ignore-pattern '*.d.ts' --ignore-pattern '*.js' --parser-options=project:tsconfig.json '*.ts' 'test/*.ts'",
|
|
75
|
+
"lint:base": "eslint --ignore-pattern '**/exclude/*' --ignore-pattern '*.compiled.*' --ignore-pattern '*.d.ts' --ignore-pattern '*.js' --parser-options=project:tsconfig.json '*.ts' 'test/*.ts'",
|
|
78
76
|
"prepare": "yarn build",
|
|
79
77
|
"postversion": "yarn publish --non-interactive; git push --tags && git push",
|
|
80
78
|
"prettify": "yarn lint:base --fix || true",
|
|
@@ -83,7 +81,7 @@
|
|
|
83
81
|
"test:coverage:report": "yarn test:coverage --coverageDirectory=.coverage --coverageReporters=lcov --outputFile=lcov.info",
|
|
84
82
|
"test:watch": "yarn test --watch",
|
|
85
83
|
"test:watch:all": "yarn test --watchAll",
|
|
86
|
-
"update": "yarn version --
|
|
84
|
+
"update": "yarn version patch && git push --tags",
|
|
87
85
|
"update:documentation": "documentation-website"
|
|
88
86
|
},
|
|
89
87
|
"runkitExample": "require('@babel/runtime/package.json')\n\nconst {default: main} = require('weboptimizer')\n\nawait main('./', './', ['clear'])",
|
|
@@ -304,7 +302,8 @@
|
|
|
304
302
|
},
|
|
305
303
|
"engines": {
|
|
306
304
|
"node": ">=18",
|
|
307
|
-
"npm": ">=9"
|
|
305
|
+
"npm": ">=9",
|
|
306
|
+
"yarn": ">=3"
|
|
308
307
|
},
|
|
309
308
|
"resolutions": {
|
|
310
309
|
"colors": "1.4.0"
|
|
@@ -1917,5 +1916,6 @@
|
|
|
1917
1916
|
"jsdoc/require-returns-description": "error",
|
|
1918
1917
|
"jsdoc/require-returns-type": 0
|
|
1919
1918
|
}
|
|
1920
|
-
}
|
|
1921
|
-
|
|
1919
|
+
},
|
|
1920
|
+
"packageManager": "yarn@4.1.0+sha256.81a00df816059803e6b5148acf03ce313cad36b7f6e5af6efa040a15981a6ffb"
|
|
1921
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/test/browser.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// #!/usr/bin/env babel-node
|
|
2
|
+
// -*- coding: utf-8 -*-
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
// region imports
|
|
6
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
7
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
8
|
+
var _globals = require("@jest/globals");
|
|
9
|
+
var _clientnode = _interopRequireDefault(require("clientnode"));
|
|
10
|
+
var _browser = _interopRequireWildcard(require("../browser"));
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
13
|
+
// endregion
|
|
14
|
+
(0, _globals.test)('browser', function (done) {
|
|
15
|
+
(0, _globals.expect)(_browser.browser.debug).toStrictEqual(false);
|
|
16
|
+
(0, _globals.expect)(_browser.browser.domContentLoaded).toStrictEqual(false);
|
|
17
|
+
(0, _globals.expect)(_browser.browser.initialized).toStrictEqual(false);
|
|
18
|
+
(0, _globals.expect)(_browser.browser.windowLoaded).toStrictEqual(false);
|
|
19
|
+
(0, _browser["default"])().then(function (initializedBrowser) {
|
|
20
|
+
(0, _globals.expect)(initializedBrowser).toStrictEqual(_browser.browser);
|
|
21
|
+
(0, _globals.expect)(_browser.browser.initialized).toStrictEqual(true);
|
|
22
|
+
(0, _globals.expect)(_browser.browser.window).toHaveProperty('document');
|
|
23
|
+
if (_browser.browser.window) (0, _globals.expect)(_browser.browser.window.document).toHaveProperty('location');
|
|
24
|
+
var onWindowLoaded = function onWindowLoaded(event) {
|
|
25
|
+
(0, _globals.expect)(event).toBeInstanceOf(Object);
|
|
26
|
+
(0, _globals.expect)(_browser.browser.domContentLoaded).toStrictEqual(true);
|
|
27
|
+
if (_browser.browser.window) (0, _globals.expect)(_browser.browser.window.document.querySelector('body')).toBeInstanceOf(Object);
|
|
28
|
+
(0, _globals.expect)(_browser.browser.windowLoaded).toStrictEqual(true);
|
|
29
|
+
done();
|
|
30
|
+
};
|
|
31
|
+
if (_browser.browser.windowLoaded) onWindowLoaded(new Event('load'));else if (_browser.browser.window) _browser.browser.window.addEventListener('load', onWindowLoaded);else done();
|
|
32
|
+
}, _clientnode["default"].noop);
|
|
33
|
+
});
|
|
34
|
+
// region vim modline
|
|
35
|
+
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
36
|
+
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
37
|
+
// endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// #!/usr/bin/env babel-node
|
|
2
|
+
// -*- coding: utf-8 -*-
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
// region imports
|
|
6
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
7
|
+
var _globals = require("@jest/globals");
|
|
8
|
+
var _configurator = _interopRequireDefault(require("../configurator"));
|
|
9
|
+
// endregion
|
|
10
|
+
(0, _globals.test)('loadConfiguration', function () {
|
|
11
|
+
return (0, _globals.expect)((0, _configurator["default"])()).toHaveProperty('name', 'mockup');
|
|
12
|
+
});
|
|
13
|
+
// region vim modline
|
|
14
|
+
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
15
|
+
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
16
|
+
// endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// #!/usr/bin/env babel-node
|
|
2
|
+
// -*- coding: utf-8 -*-
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
// region imports
|
|
6
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
7
|
+
var _globals = require("@jest/globals");
|
|
8
|
+
var _clientnode = _interopRequireDefault(require("clientnode"));
|
|
9
|
+
var _ejsLoader = _interopRequireDefault(require("../ejsLoader"));
|
|
10
|
+
// endregion
|
|
11
|
+
// region mockup
|
|
12
|
+
var context = {
|
|
13
|
+
debug: false,
|
|
14
|
+
loaders: [],
|
|
15
|
+
resourcePath: '',
|
|
16
|
+
query: ''
|
|
17
|
+
};
|
|
18
|
+
// endregion
|
|
19
|
+
(0, _globals.describe)('ejsLoader', function () {
|
|
20
|
+
// region tests
|
|
21
|
+
(0, _globals.test)('loader', function () {
|
|
22
|
+
(0, _globals.expect)(_ejsLoader["default"].call(context, '<a></a>')).toStrictEqual('<a></a>');
|
|
23
|
+
var complexContext = _clientnode["default"].extend(true, _clientnode["default"].copy(context), {
|
|
24
|
+
cacheable: _clientnode["default"].noop,
|
|
25
|
+
getOptions: function getOptions() {
|
|
26
|
+
return this.query;
|
|
27
|
+
},
|
|
28
|
+
query: {
|
|
29
|
+
compiler: {
|
|
30
|
+
strict: true
|
|
31
|
+
},
|
|
32
|
+
locals: {
|
|
33
|
+
test: 'hans'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
(0, _globals.expect)(_ejsLoader["default"].call(complexContext, '<a><%- test %></a>')).toStrictEqual('<a>hans</a>');
|
|
38
|
+
(0, _globals.expect)(_ejsLoader["default"].call(complexContext, "<a></a><%- include('<a>test</a>?{options: {isString: true}}') %>")).toStrictEqual('<a></a><a>test</a>');
|
|
39
|
+
complexContext.query.compileSteps = 0;
|
|
40
|
+
(0, _globals.expect)(_ejsLoader["default"].call(complexContext, '<a></a>')).toStrictEqual('<a></a>');
|
|
41
|
+
complexContext.query.compileSteps = 1;
|
|
42
|
+
(0, _globals.expect)(_ejsLoader["default"].call(complexContext, '<a></a>').startsWith("'use strict';\nmodule.exports=")).toStrictEqual(true);
|
|
43
|
+
complexContext.query.compileSteps = 2;
|
|
44
|
+
(0, _globals.expect)(_ejsLoader["default"].call(complexContext, '<a></a>')).toStrictEqual('<a></a>');
|
|
45
|
+
complexContext.query.compileSteps = 3;
|
|
46
|
+
(0, _globals.expect)(_ejsLoader["default"].call(complexContext, '<a></a>').startsWith("'use strict';\nmodule.exports=")).toStrictEqual(true);
|
|
47
|
+
});
|
|
48
|
+
// endregion
|
|
49
|
+
});
|
|
50
|
+
// region vim modline
|
|
51
|
+
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
52
|
+
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
53
|
+
// endregion
|
package/test/helper.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/test/helper.js
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
// #!/usr/bin/env babel-node
|
|
2
|
+
// -*- coding: utf-8 -*-
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
// region imports
|
|
6
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
7
|
+
var _globals = require("@jest/globals");
|
|
8
|
+
var _clientnode = require("clientnode");
|
|
9
|
+
var _testHelper = require("clientnode/testHelper");
|
|
10
|
+
var _path = require("path");
|
|
11
|
+
var _helper = _interopRequireDefault(require("../helper"));
|
|
12
|
+
// endregion
|
|
13
|
+
// region mockup
|
|
14
|
+
var buildConfiguration = {
|
|
15
|
+
example: {
|
|
16
|
+
extension: 'example',
|
|
17
|
+
filePathPattern: '',
|
|
18
|
+
ignoredExtension: '',
|
|
19
|
+
outputExtension: 'example'
|
|
20
|
+
},
|
|
21
|
+
javaScript: {
|
|
22
|
+
extension: 'js',
|
|
23
|
+
filePathPattern: '',
|
|
24
|
+
ignoredExtension: '',
|
|
25
|
+
outputExtension: 'js'
|
|
26
|
+
},
|
|
27
|
+
other: {
|
|
28
|
+
extension: 'other',
|
|
29
|
+
filePathPattern: '',
|
|
30
|
+
ignoredExtension: '',
|
|
31
|
+
outputExtension: 'other'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
// endregion
|
|
35
|
+
(0, _globals.describe)('helper', function () {
|
|
36
|
+
// region tests
|
|
37
|
+
/// region boolean
|
|
38
|
+
(0, _testHelper.testEach)('isFilePathInLocation', _helper["default"].isFilePathInLocation, [true, './', ['./']], [true, './', ['../']], [false, '../', ['./']]);
|
|
39
|
+
/// endregion
|
|
40
|
+
/// region string
|
|
41
|
+
(0, _testHelper.testEach)('stripLoader', _helper["default"].stripLoader, ['', ''], ['a', 'a'], ['b', 'a!b'], ['c', 'aa!b!c'], ['c', 'aa!b!c'], ['c', 'c?a'], ['c', 'aa!b!c?a'], ['c', 'aa!b!c?abb?'], ['c', 'aa!b!c?abb?a'], ['moduleName', 'imports?$=library!moduleName']);
|
|
42
|
+
/// endregion
|
|
43
|
+
/// region array
|
|
44
|
+
(0, _testHelper.testEach)('normalizePaths', _helper["default"].normalizePaths, [[], []], [['a'], ['a']], [['a'], ['a/']], [['a'], ['a/', 'a']], [['a'], ['a/', 'a/']], [['a', 'b'], ['a/', 'a/', 'b/']], [['a', 'b'], ['a/', 'a/', 'b']], [['a', 'b', '.'], ['a/', 'a/', 'b', '', '.']]);
|
|
45
|
+
/// endregion
|
|
46
|
+
/// region file handler
|
|
47
|
+
(0, _testHelper.testEach)('renderFilePathTemplate', _helper["default"].renderFilePathTemplate, ['', '', {}], ['a', 'a', {}], ['path', 'path', {}], ['a.__dummy__b', 'a[name]b', {}], ['a.__dummy__b.__dummy__', 'a[name]b[name]', {}], ['a.__dummy__b.__dummy__', 'a[id]b[chunkhash]', {}], ['a1b2', 'a[id]b[chunkhash]', {
|
|
48
|
+
'[id]': 1,
|
|
49
|
+
'[chunkhash]': 2
|
|
50
|
+
}], ['a[id]b[chunkhash]', 'a[id]b[chunkhash]', {
|
|
51
|
+
'[id]': '[id]',
|
|
52
|
+
'[chunkhash]': '[chunkhash]'
|
|
53
|
+
}]);
|
|
54
|
+
(0, _testHelper.testEach)('applyContext', _helper["default"].applyContext, ['', ''], ['a', 'a'], ['a', 'a', './'], ['./a', './a', './'], ['./a', './a', './', './'], ['a/a', './a', './a', './'], ['./a', './a', './a', './a'], ['./a', './a', './a', './a', {
|
|
55
|
+
a: 'b'
|
|
56
|
+
}], ['b/a', './a', './a/a', './', {
|
|
57
|
+
a: 'b'
|
|
58
|
+
}, {}, ['a']]);
|
|
59
|
+
(0, _testHelper.testEach)('determineExternalRequest', _helper["default"].determineExternalRequest, [null, ''], ['a', 'a'], ['path', 'path'], [null, './helper'], [null, './helper', './'], [null, './helper', '../'], ['./helper', './helper', './a'], [null, './helper', './', './'], ['a/a', './a', './', './node_modules/a'], ['a', './', './', 'a'], ['path', 'path', './', './', {}, []], ['./main.js', 'path', './', './', {}, [], {
|
|
60
|
+
path: './main.js'
|
|
61
|
+
}], ['main.js', 'path', './', './', {}, [], {
|
|
62
|
+
path: 'main.js'
|
|
63
|
+
}], [null, 'path', './', './', {}, [], {
|
|
64
|
+
path: './helper.ts'
|
|
65
|
+
}], ['webpack', 'webpack'], ['webpack', 'a', './', './', {}, ['node_modules'], {
|
|
66
|
+
a$: 'webpack'
|
|
67
|
+
}], [null, 'a', './', './', {
|
|
68
|
+
a: ['webpack']
|
|
69
|
+
}, ['node_modules'], {
|
|
70
|
+
a$: 'webpack'
|
|
71
|
+
}], ['webpack', 'a', '../', './', {
|
|
72
|
+
a: ['not_webpack']
|
|
73
|
+
}, ['node_modules'], {
|
|
74
|
+
a$: 'webpack'
|
|
75
|
+
}, {}, {
|
|
76
|
+
file: {
|
|
77
|
+
external: [],
|
|
78
|
+
internal: []
|
|
79
|
+
}
|
|
80
|
+
}], ['webpack', 'a', '../', './', {
|
|
81
|
+
a: ['webpack']
|
|
82
|
+
}, ['node_modules'], {
|
|
83
|
+
a$: 'webpack'
|
|
84
|
+
}, {}, {
|
|
85
|
+
file: {
|
|
86
|
+
external: ['.js'],
|
|
87
|
+
internal: ['.js']
|
|
88
|
+
}
|
|
89
|
+
}, './', ['./']], [null, 'a', './', './', {
|
|
90
|
+
a: ['webpack']
|
|
91
|
+
}, ['node_modules'], {
|
|
92
|
+
a$: 'webpack'
|
|
93
|
+
}, {}, {
|
|
94
|
+
file: {
|
|
95
|
+
external: ['.js'],
|
|
96
|
+
internal: ['.js']
|
|
97
|
+
}
|
|
98
|
+
}, './', ['.git']], ['webpack', 'a', './', './', {
|
|
99
|
+
a: ['webpack']
|
|
100
|
+
}, ['node_modules'], {
|
|
101
|
+
a$: 'webpack'
|
|
102
|
+
}, {}, {
|
|
103
|
+
file: {
|
|
104
|
+
external: ['.js'],
|
|
105
|
+
internal: ['.js']
|
|
106
|
+
}
|
|
107
|
+
}, './', ['.git'], [], [], [], [], ['webpack']], ['webpack', 'webpack', './', '../', {}, ['node_modules'], {}, {}, {
|
|
108
|
+
file: {
|
|
109
|
+
external: ['.js'],
|
|
110
|
+
internal: ['.js']
|
|
111
|
+
}
|
|
112
|
+
}, './', ['.git'], ['node_modules'], ['main'], ['main'], [], [], []], ['webpack', 'webpack', './', '../', {}, ['node_modules'], {}, {}, {
|
|
113
|
+
file: {
|
|
114
|
+
external: ['.js'],
|
|
115
|
+
internal: ['.js']
|
|
116
|
+
}
|
|
117
|
+
}, './', ['.git'], ['node_modules'], ['main'], ['main'], [], [], [], false], [null, 'webpack', './', '../', {}, ['node_modules'], {}, {}, {
|
|
118
|
+
file: {
|
|
119
|
+
external: ['.js'],
|
|
120
|
+
internal: ['.js']
|
|
121
|
+
}
|
|
122
|
+
}, './', ['.git'], ['node_modules'], ['main'], ['main'], [], [], [], true], [null, 'a!webpack', './', '../', {}, ['node_modules'], {}, {}, {
|
|
123
|
+
file: {
|
|
124
|
+
external: ['.js'],
|
|
125
|
+
internal: ['.js']
|
|
126
|
+
}
|
|
127
|
+
}, './', ['.git'], ['node_modules'], ['main'], ['main'], [], [], [], false], [null, 'a!webpack', './', '../', {}, ['node_modules'], {}, {}, {
|
|
128
|
+
file: {
|
|
129
|
+
external: ['.js'],
|
|
130
|
+
internal: ['.js']
|
|
131
|
+
}
|
|
132
|
+
}, './', ['.git'], ['node_modules'], ['main'], ['main'], [], [], [], false, true], ['webpack', 'a!webpack', './', '../', {}, ['node_modules'], {}, {}, {
|
|
133
|
+
file: {
|
|
134
|
+
external: ['.js'],
|
|
135
|
+
internal: ['.js']
|
|
136
|
+
}
|
|
137
|
+
}, './', ['.git'], ['node_modules'], ['main'], ['main'], [], [], [], false, false], [null, 'a!webpack', './', '../', {}, ['node_modules'], {}, {}, {
|
|
138
|
+
file: {
|
|
139
|
+
external: ['.eot'],
|
|
140
|
+
internal: ['.js']
|
|
141
|
+
}
|
|
142
|
+
}, './', ['.git'], ['node_modules'], ['main'], ['main'], [], [], [], false, false]);
|
|
143
|
+
_globals.test.each([[null, './'], ['javaScript', 'a.js'], [null, 'a.css']])("%p === determineAssetType('%s')", function (expected, parameter) {
|
|
144
|
+
var paths = {
|
|
145
|
+
apiDocumentation: '',
|
|
146
|
+
base: '',
|
|
147
|
+
configuration: {
|
|
148
|
+
javaScript: '',
|
|
149
|
+
json: '',
|
|
150
|
+
typeScript: ''
|
|
151
|
+
},
|
|
152
|
+
context: '',
|
|
153
|
+
ignore: [],
|
|
154
|
+
source: {
|
|
155
|
+
asset: {
|
|
156
|
+
base: '',
|
|
157
|
+
cascadingStyleSheet: '',
|
|
158
|
+
data: '',
|
|
159
|
+
font: '',
|
|
160
|
+
image: '',
|
|
161
|
+
javaScript: '',
|
|
162
|
+
template: ''
|
|
163
|
+
},
|
|
164
|
+
base: ''
|
|
165
|
+
},
|
|
166
|
+
target: {
|
|
167
|
+
asset: {
|
|
168
|
+
base: '',
|
|
169
|
+
cascadingStyleSheet: '',
|
|
170
|
+
data: '',
|
|
171
|
+
font: '',
|
|
172
|
+
image: '',
|
|
173
|
+
javaScript: '',
|
|
174
|
+
template: ''
|
|
175
|
+
},
|
|
176
|
+
base: '',
|
|
177
|
+
manifest: '',
|
|
178
|
+
"public": ''
|
|
179
|
+
},
|
|
180
|
+
tidyUp: [],
|
|
181
|
+
tidyUpGlobs: [],
|
|
182
|
+
tidyUpOnClear: [],
|
|
183
|
+
tidyUpOnClearGlobs: []
|
|
184
|
+
};
|
|
185
|
+
(0, _globals.expect)(_helper["default"].determineAssetType(parameter, buildConfiguration, paths)).toStrictEqual(expected);
|
|
186
|
+
});
|
|
187
|
+
(0, _globals.test)('resolveBuildConfigurationFilePaths', function () {
|
|
188
|
+
(0, _globals.expect)(_helper["default"].resolveBuildConfigurationFilePaths({})).toStrictEqual([]);
|
|
189
|
+
(0, _globals.expect)(_helper["default"].resolveBuildConfigurationFilePaths(buildConfiguration, './', ['.git', 'node_modules'])).toStrictEqual([{
|
|
190
|
+
extension: 'js',
|
|
191
|
+
filePathPattern: '',
|
|
192
|
+
filePaths: [],
|
|
193
|
+
ignoredExtension: '',
|
|
194
|
+
outputExtension: 'js'
|
|
195
|
+
}, {
|
|
196
|
+
extension: 'example',
|
|
197
|
+
filePathPattern: '',
|
|
198
|
+
filePaths: [],
|
|
199
|
+
ignoredExtension: '',
|
|
200
|
+
outputExtension: 'example'
|
|
201
|
+
}, {
|
|
202
|
+
extension: 'other',
|
|
203
|
+
filePathPattern: '',
|
|
204
|
+
filePaths: [],
|
|
205
|
+
ignoredExtension: '',
|
|
206
|
+
outputExtension: 'other'
|
|
207
|
+
}]);
|
|
208
|
+
});
|
|
209
|
+
(0, _testHelper.testEach)('determineModuleLocations', _helper["default"].determineModuleLocations, [{
|
|
210
|
+
filePaths: [],
|
|
211
|
+
directoryPaths: []
|
|
212
|
+
}, {}], [{
|
|
213
|
+
filePaths: [],
|
|
214
|
+
directoryPaths: []
|
|
215
|
+
}, 'example'], [{
|
|
216
|
+
directoryPaths: [(0, _path.resolve)(__dirname, '../')],
|
|
217
|
+
filePaths: [(0, _path.resolve)(__dirname, '../helper.js')]
|
|
218
|
+
}, 'helper'], [{
|
|
219
|
+
filePaths: [],
|
|
220
|
+
directoryPaths: []
|
|
221
|
+
}, {
|
|
222
|
+
example: 'example'
|
|
223
|
+
}], [{
|
|
224
|
+
directoryPaths: [(0, _path.resolve)(__dirname, '../')],
|
|
225
|
+
filePaths: [(0, _path.resolve)(__dirname, '../helper.js')]
|
|
226
|
+
}, {
|
|
227
|
+
example: 'helper'
|
|
228
|
+
}], [{
|
|
229
|
+
directoryPaths: [(0, _path.resolve)(__dirname, '../')],
|
|
230
|
+
filePaths: [(0, _path.resolve)(__dirname, '../', 'helper.ts')]
|
|
231
|
+
}, {
|
|
232
|
+
helper: ['helper.ts']
|
|
233
|
+
}]);
|
|
234
|
+
(0, _testHelper.testEach)('resolveModulesInFolders', _helper["default"].resolveModulesInFolders, [{}, {}], [{
|
|
235
|
+
index: []
|
|
236
|
+
}, {
|
|
237
|
+
index: []
|
|
238
|
+
}]);
|
|
239
|
+
(0, _globals.test)('resolveModulesInFolders', function () {
|
|
240
|
+
return (0, _globals.expect)(_helper["default"].resolveModulesInFolders({
|
|
241
|
+
a: [__dirname]
|
|
242
|
+
}).a).toContain('./test/helper.ts');
|
|
243
|
+
});
|
|
244
|
+
(0, _testHelper.testEach)('normalizeGivenInjection', _helper["default"].normalizeGivenInjection, [{
|
|
245
|
+
index: []
|
|
246
|
+
}, []], [{
|
|
247
|
+
index: []
|
|
248
|
+
}, {}], [{
|
|
249
|
+
index: ['example']
|
|
250
|
+
}, 'example'], [{
|
|
251
|
+
index: ['example']
|
|
252
|
+
}, ['example']], [{
|
|
253
|
+
a: ['example']
|
|
254
|
+
}, {
|
|
255
|
+
a: 'example'
|
|
256
|
+
}], [{
|
|
257
|
+
a: ['example']
|
|
258
|
+
}, {
|
|
259
|
+
a: ['example']
|
|
260
|
+
}], [{
|
|
261
|
+
a: ['example']
|
|
262
|
+
}, {
|
|
263
|
+
a: ['example'],
|
|
264
|
+
b: []
|
|
265
|
+
}], [{
|
|
266
|
+
index: []
|
|
267
|
+
}, {
|
|
268
|
+
a: [],
|
|
269
|
+
b: []
|
|
270
|
+
}]);
|
|
271
|
+
(0, _testHelper.testEach)('resolveAutoInjection', _helper["default"].resolveAutoInjection, [{
|
|
272
|
+
autoExclude: [],
|
|
273
|
+
entry: [],
|
|
274
|
+
external: {}
|
|
275
|
+
}, {
|
|
276
|
+
autoExclude: [],
|
|
277
|
+
entry: [],
|
|
278
|
+
external: {}
|
|
279
|
+
}, _helper["default"].resolveBuildConfigurationFilePaths(buildConfiguration, './', ['.git', 'node_modules']), {}, {}, {
|
|
280
|
+
file: {
|
|
281
|
+
external: [],
|
|
282
|
+
internal: []
|
|
283
|
+
}
|
|
284
|
+
}, './', '', ['.git', 'node_modules']], [{
|
|
285
|
+
autoExclude: [],
|
|
286
|
+
entry: 'a.js',
|
|
287
|
+
external: []
|
|
288
|
+
}, {
|
|
289
|
+
autoExclude: [],
|
|
290
|
+
entry: 'a.js',
|
|
291
|
+
external: []
|
|
292
|
+
}, _helper["default"].resolveBuildConfigurationFilePaths(buildConfiguration, './', ['.git', 'node_modules']), {}, {}, {
|
|
293
|
+
file: {
|
|
294
|
+
external: [],
|
|
295
|
+
internal: []
|
|
296
|
+
}
|
|
297
|
+
}, './', '', ['.git', 'node_modules']], [{
|
|
298
|
+
autoExclude: [],
|
|
299
|
+
entry: ['a'],
|
|
300
|
+
external: []
|
|
301
|
+
}, {
|
|
302
|
+
autoExclude: [],
|
|
303
|
+
entry: ['a'],
|
|
304
|
+
external: []
|
|
305
|
+
}, _helper["default"].resolveBuildConfigurationFilePaths(buildConfiguration, './', ['.git', 'node_modules']), {}, {}, {
|
|
306
|
+
file: {
|
|
307
|
+
external: [],
|
|
308
|
+
internal: []
|
|
309
|
+
}
|
|
310
|
+
}, './', '', ['.git', 'node_modules']], [{
|
|
311
|
+
autoExclude: [],
|
|
312
|
+
entry: {},
|
|
313
|
+
external: []
|
|
314
|
+
}, {
|
|
315
|
+
autoExclude: [],
|
|
316
|
+
entry: '__auto__',
|
|
317
|
+
external: []
|
|
318
|
+
}, _helper["default"].resolveBuildConfigurationFilePaths(buildConfiguration, './', ['.git', 'node_modules']), {}, {}, {
|
|
319
|
+
file: {
|
|
320
|
+
external: [],
|
|
321
|
+
internal: []
|
|
322
|
+
}
|
|
323
|
+
}, './', '', ['.git', 'node_modules']], [{
|
|
324
|
+
autoExclude: [],
|
|
325
|
+
entry: {
|
|
326
|
+
index: []
|
|
327
|
+
},
|
|
328
|
+
external: []
|
|
329
|
+
}, {
|
|
330
|
+
autoExclude: [],
|
|
331
|
+
entry: {
|
|
332
|
+
index: '__auto__'
|
|
333
|
+
},
|
|
334
|
+
external: []
|
|
335
|
+
}, _helper["default"].resolveBuildConfigurationFilePaths(buildConfiguration, './', ['.git', 'node_modules']), {}, {}, {
|
|
336
|
+
file: {
|
|
337
|
+
external: [],
|
|
338
|
+
internal: []
|
|
339
|
+
}
|
|
340
|
+
}, './', '', ['.git', 'node_modules']]);
|
|
341
|
+
(0, _globals.test)('getAutoInjection', function () {
|
|
342
|
+
return (0, _globals.expect)(_helper["default"].getAutoInjection(_helper["default"].resolveBuildConfigurationFilePaths(buildConfiguration, './', ['.git', 'node_modules']), ['.git', 'node_modules'], './')).toStrictEqual({});
|
|
343
|
+
});
|
|
344
|
+
(0, _testHelper.testEach)('determineModuleFilePath', _helper["default"].determineModuleFilePath, [null, ''], [null, 'a', {}, {}, {
|
|
345
|
+
file: []
|
|
346
|
+
}, './', '', []], [null, 'a', {
|
|
347
|
+
a: 'b'
|
|
348
|
+
}, {}, {
|
|
349
|
+
file: []
|
|
350
|
+
}, './', '', []], [null, 'bba', {
|
|
351
|
+
a: 'b'
|
|
352
|
+
}, {}, {
|
|
353
|
+
file: []
|
|
354
|
+
}, './', '', []], [(0, _path.resolve)('helper.js'), 'helper'], [null, 'helper', {}, {}, {
|
|
355
|
+
file: []
|
|
356
|
+
}, './', '', []], [null, './helper', {}, {}, {
|
|
357
|
+
file: ['.ts']
|
|
358
|
+
}, '', 'a', []], [(0, _path.resolve)('helper.ts'), 'helper', {}, {}, {
|
|
359
|
+
file: ['.ts']
|
|
360
|
+
}, './', './']);
|
|
361
|
+
/// endregion
|
|
362
|
+
(0, _testHelper.testEach)('applyAliases', _helper["default"].applyAliases, ['', '', {}], ['', '', {
|
|
363
|
+
a: 'b'
|
|
364
|
+
}], ['a', 'a', {}], ['b', 'a', {
|
|
365
|
+
a: 'b'
|
|
366
|
+
}], ['b', 'a', {
|
|
367
|
+
a$: 'b'
|
|
368
|
+
}], ['aa', 'aa', {
|
|
369
|
+
a$: 'b'
|
|
370
|
+
}], ['bbb', 'bba', {
|
|
371
|
+
a: 'b'
|
|
372
|
+
}], ['helper', 'helper', {}]);
|
|
373
|
+
(0, _testHelper.testEach)('applyModuleReplacements', _helper["default"].applyModuleReplacements, ['', '', {}], ['', '', {
|
|
374
|
+
a: 'b'
|
|
375
|
+
}], ['a', 'a', {}], ['b', 'a', {
|
|
376
|
+
a: 'b'
|
|
377
|
+
}], ['b', 'a', {
|
|
378
|
+
a$: 'b'
|
|
379
|
+
}], ['b', 'a', {
|
|
380
|
+
'^a$': 'b'
|
|
381
|
+
}], ['ba', 'aa', {
|
|
382
|
+
a: 'b'
|
|
383
|
+
}], ['helper', 'helper', {}]);
|
|
384
|
+
(0, _testHelper.testEachAgainstSameExpectation)('findPackageDescriptorFilePath', _helper["default"].findPackageDescriptorFilePath, (0, _path.resolve)(__dirname, '../package.json'), ['./', 'package.json'], ['../', 'package.json']);
|
|
385
|
+
_globals.test.each([['./'], ['../']])("getClosestPackageDescriptor('%s') === {configuration: ...}", function (modulePath) {
|
|
386
|
+
var filePath = (0, _path.resolve)(__dirname, '../package.json');
|
|
387
|
+
(0, _globals.expect)(_helper["default"].getClosestPackageDescriptor(modulePath, filePath)).toStrictEqual({
|
|
388
|
+
configuration: (0, _clientnode.currentRequire)(filePath),
|
|
389
|
+
filePath: filePath
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
// endregion
|
|
393
|
+
});
|
|
394
|
+
// region vim modline
|
|
395
|
+
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
396
|
+
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
397
|
+
// endregion
|
package/test/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/test/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// #!/usr/bin/env babel-node
|
|
2
|
+
// -*- coding: utf-8 -*-
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
// region imports
|
|
6
|
+
var _globals = require("@jest/globals");
|
|
7
|
+
var _child_process = require("child_process");
|
|
8
|
+
var _fs = require("fs");
|
|
9
|
+
var _path = require("path");
|
|
10
|
+
// endregion
|
|
11
|
+
/*
|
|
12
|
+
NOTE: Theses tasks can take lot longer than 5 seconds (default
|
|
13
|
+
configuration).
|
|
14
|
+
*/
|
|
15
|
+
_globals.jest.setTimeout(60 * 1000);
|
|
16
|
+
var _loop = function _loop() {
|
|
17
|
+
var folder = _arr[_i];
|
|
18
|
+
// Enforce test folder to be handled as dedicated projects via yarn.
|
|
19
|
+
(0, _fs.closeSync)((0, _fs.openSync)((0, _path.resolve)(__dirname, folder, 'yarn.lock'), 'w'));
|
|
20
|
+
(0, _child_process.spawnSync)('yarn', ['install'], {
|
|
21
|
+
cwd: (0, _path.resolve)(__dirname, folder),
|
|
22
|
+
env: process.env,
|
|
23
|
+
shell: true,
|
|
24
|
+
stdio: 'inherit'
|
|
25
|
+
});
|
|
26
|
+
_globals.test.each(['check:types', 'lint', 'build', 'test'])("index (".concat(folder, ":%s)"), function (command) {
|
|
27
|
+
for (var _i2 = 0, _arr2 = ['clear', command, 'clear']; _i2 < _arr2.length; _i2++) {
|
|
28
|
+
var currentCommand = _arr2[_i2];
|
|
29
|
+
(0, _globals.expect)((0, _child_process.spawnSync)('yarn', ['weboptimizer', currentCommand], {
|
|
30
|
+
cwd: (0, _path.resolve)(__dirname, folder),
|
|
31
|
+
env: process.env,
|
|
32
|
+
shell: true,
|
|
33
|
+
stdio: 'inherit'
|
|
34
|
+
}).status).toStrictEqual(0);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
for (var _i = 0, _arr = ['simple', 'scss']; _i < _arr.length; _i++) {
|
|
39
|
+
_loop();
|
|
40
|
+
}
|
|
41
|
+
// region vim modline
|
|
42
|
+
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
43
|
+
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
44
|
+
// endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// #!/usr/bin/env babel-node
|
|
2
|
+
// -*- coding: utf-8 -*-
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
// region imports
|
|
6
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
7
|
+
var _globals = require("@jest/globals");
|
|
8
|
+
var _stylelintConfigurator = _interopRequireDefault(require("../stylelintConfigurator"));
|
|
9
|
+
// endregion
|
|
10
|
+
(0, _globals.test)('stylelintConfigurator', function () {
|
|
11
|
+
return (0, _globals.expect)(_stylelintConfigurator["default"]).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
// region vim modline
|
|
14
|
+
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
15
|
+
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
16
|
+
// endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|