js-build-tools 5.3.2 → 5.4.0
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/dist/build.js +63 -63
- package/dist/bundle.js +34 -27
- package/dist/bundle.min.js +1 -1
- package/dist/partials/imagesFor.js +42 -42
- package/dist/partials/loadPeer.js +70 -70
- package/dist/partials/standardLint.js +73 -73
- package/dist/partials/tsFor.js +70 -70
- package/dist/partials.js +136 -136
- package/dist/typeDocs.js +9 -9
- package/functions/bundle.mjs +6 -1
- package/functions/bundle.test.mjs +20 -0
- package/package.json +1 -1
package/dist/build.js
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
-
Object.defineProperty(exports, '__esModule', {
|
|
5
|
-
value: true
|
|
6
|
-
})
|
|
7
|
-
exports.build = void 0
|
|
8
|
-
const _bundle = require('./bundle.js')
|
|
9
|
-
const _bundleLint = require('./bundleLint.js')
|
|
10
|
-
const _bundleMinify = require('./bundleMinify.js')
|
|
11
|
-
const _partials = require('./partials.js')
|
|
12
|
-
const _compileReadme = require('./compileReadme.js')
|
|
13
|
-
const _typeDocs = require('./typeDocs.js')
|
|
14
|
-
const _distLint = require('./distLint.js')
|
|
15
|
-
const _distMinify = require('./distMinify.js')
|
|
16
|
-
const _gulp = require('gulp')
|
|
17
|
-
const gulpConfig = _interopRequireWildcard(require('../gulp.config.js'))
|
|
18
|
-
const _copyFonts = require('./copyFonts.js')
|
|
19
|
-
const _images = require('./images.js')
|
|
20
|
-
const _sass = require('./sass.js')
|
|
21
|
-
const _testFull = require('./testFull.js')
|
|
22
|
-
function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; let o; let i; const f = { __proto__: null, default: e }; if (e === null || typeof e !== 'object' && typeof e !== 'function') return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f) } for (const t in e) t !== 'default' && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f })(e, t) }
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
+
Object.defineProperty(exports, '__esModule', {
|
|
5
|
+
value: true
|
|
6
|
+
})
|
|
7
|
+
exports.build = void 0
|
|
8
|
+
const _bundle = require('./bundle.js')
|
|
9
|
+
const _bundleLint = require('./bundleLint.js')
|
|
10
|
+
const _bundleMinify = require('./bundleMinify.js')
|
|
11
|
+
const _partials = require('./partials.js')
|
|
12
|
+
const _compileReadme = require('./compileReadme.js')
|
|
13
|
+
const _typeDocs = require('./typeDocs.js')
|
|
14
|
+
const _distLint = require('./distLint.js')
|
|
15
|
+
const _distMinify = require('./distMinify.js')
|
|
16
|
+
const _gulp = require('gulp')
|
|
17
|
+
const gulpConfig = _interopRequireWildcard(require('../gulp.config.js'))
|
|
18
|
+
const _copyFonts = require('./copyFonts.js')
|
|
19
|
+
const _images = require('./images.js')
|
|
20
|
+
const _sass = require('./sass.js')
|
|
21
|
+
const _testFull = require('./testFull.js')
|
|
22
|
+
function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; let o; let i; const f = { __proto__: null, default: e }; if (e === null || typeof e !== 'object' && typeof e !== 'function') return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f) } for (const t in e) t !== 'default' && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f })(e, t) }
|
|
23
23
|
/**
|
|
24
24
|
* Runs several processes to build and validate the project.
|
|
25
25
|
* Cleans, distributes (lint and minify), bundles (lint and minify), creates the readme, then runs the tests.
|
|
26
26
|
* @memberOf module:js-build-tools
|
|
27
27
|
* @returns {stream.Stream}
|
|
28
|
-
*/
|
|
29
|
-
const build = (done = null) => {
|
|
30
|
-
const distLintMinify = (0, _gulp.parallel)(_distLint.distLint, _distMinify.distMinify)
|
|
31
|
-
const bundleLintMinify = (0, _gulp.parallel)(_bundleLint.bundleLint, _bundleMinify.bundleMinify)
|
|
32
|
-
const buildActions = [(0, _partials.distSeries)(), distLintMinify]
|
|
33
|
-
const generateDocs = gulpConfig.get('docs.enabled')
|
|
34
|
-
if (generateDocs) {
|
|
35
|
-
// The documentation is generated from the TypeScript source itself, the readme is written by hand
|
|
36
|
-
buildActions.push(_typeDocs.typeDocs)
|
|
37
|
-
} else if (gulpConfig.get('typescript.enabled')) {
|
|
38
|
-
// For ts usage, we need to run the readme on the dist directly since that is where the .js files are located
|
|
39
|
-
buildActions.push(_compileReadme.compileReadme)
|
|
40
|
-
}
|
|
41
|
-
if (gulpConfig.get('browser.enabled')) {
|
|
42
|
-
// If not 'nodeOnly' then we also want to bundle for browser after we complete the dist directory
|
|
43
|
-
buildActions.push(_bundle.bundle)
|
|
44
|
-
buildActions.push(bundleLintMinify)
|
|
45
|
-
}
|
|
46
|
-
const runActions = [(0, _gulp.series)(...buildActions)]
|
|
47
|
-
if (!generateDocs && !gulpConfig.get('typescript.enabled')) {
|
|
48
|
-
// Since we didn't run this in series after dist because of typescript, we need to run it now. Potentially faster here.
|
|
49
|
-
runActions.push(_compileReadme.compileReadme)
|
|
50
|
-
}
|
|
51
|
-
runActions.push(_testFull.testFull)
|
|
52
|
-
if (gulpConfig.get('fonts.enabled')) {
|
|
53
|
-
// Conditionally add Fonts process
|
|
54
|
-
runActions.push(_copyFonts.copyFonts)
|
|
55
|
-
}
|
|
56
|
-
if (gulpConfig.get('images.enabled')) {
|
|
57
|
-
// Conditionally add Images process
|
|
58
|
-
runActions.push(_images.images)
|
|
59
|
-
}
|
|
60
|
-
if (gulpConfig.get('sass.enabled')) {
|
|
61
|
-
// Conditionally add SASS process
|
|
62
|
-
runActions.push(_sass.sass)
|
|
63
|
-
}
|
|
64
|
-
// clean has to finish before anything writes into the output folders - images, fonts and sass all write into
|
|
65
|
-
// browser/, so running clean in parallel with them races (ENOTEMPTY errors from clean, or output deleted mid-write).
|
|
66
|
-
return (0, _gulp.series)(_partials.clean, (0, _gulp.parallel)(...runActions))(done)
|
|
67
|
-
}
|
|
68
|
-
exports.build = build
|
|
28
|
+
*/
|
|
29
|
+
const build = (done = null) => {
|
|
30
|
+
const distLintMinify = (0, _gulp.parallel)(_distLint.distLint, _distMinify.distMinify)
|
|
31
|
+
const bundleLintMinify = (0, _gulp.parallel)(_bundleLint.bundleLint, _bundleMinify.bundleMinify)
|
|
32
|
+
const buildActions = [(0, _partials.distSeries)(), distLintMinify]
|
|
33
|
+
const generateDocs = gulpConfig.get('docs.enabled')
|
|
34
|
+
if (generateDocs) {
|
|
35
|
+
// The documentation is generated from the TypeScript source itself, the readme is written by hand
|
|
36
|
+
buildActions.push(_typeDocs.typeDocs)
|
|
37
|
+
} else if (gulpConfig.get('typescript.enabled')) {
|
|
38
|
+
// For ts usage, we need to run the readme on the dist directly since that is where the .js files are located
|
|
39
|
+
buildActions.push(_compileReadme.compileReadme)
|
|
40
|
+
}
|
|
41
|
+
if (gulpConfig.get('browser.enabled')) {
|
|
42
|
+
// If not 'nodeOnly' then we also want to bundle for browser after we complete the dist directory
|
|
43
|
+
buildActions.push(_bundle.bundle)
|
|
44
|
+
buildActions.push(bundleLintMinify)
|
|
45
|
+
}
|
|
46
|
+
const runActions = [(0, _gulp.series)(...buildActions)]
|
|
47
|
+
if (!generateDocs && !gulpConfig.get('typescript.enabled')) {
|
|
48
|
+
// Since we didn't run this in series after dist because of typescript, we need to run it now. Potentially faster here.
|
|
49
|
+
runActions.push(_compileReadme.compileReadme)
|
|
50
|
+
}
|
|
51
|
+
runActions.push(_testFull.testFull)
|
|
52
|
+
if (gulpConfig.get('fonts.enabled')) {
|
|
53
|
+
// Conditionally add Fonts process
|
|
54
|
+
runActions.push(_copyFonts.copyFonts)
|
|
55
|
+
}
|
|
56
|
+
if (gulpConfig.get('images.enabled')) {
|
|
57
|
+
// Conditionally add Images process
|
|
58
|
+
runActions.push(_images.images)
|
|
59
|
+
}
|
|
60
|
+
if (gulpConfig.get('sass.enabled')) {
|
|
61
|
+
// Conditionally add SASS process
|
|
62
|
+
runActions.push(_sass.sass)
|
|
63
|
+
}
|
|
64
|
+
// clean has to finish before anything writes into the output folders - images, fonts and sass all write into
|
|
65
|
+
// browser/, so running clean in parallel with them races (ENOTEMPTY errors from clean, or output deleted mid-write).
|
|
66
|
+
return (0, _gulp.series)(_partials.clean, (0, _gulp.parallel)(...runActions))(done)
|
|
67
|
+
}
|
|
68
|
+
exports.build = build
|
package/dist/bundle.js
CHANGED
|
@@ -1,36 +1,43 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
-
Object.defineProperty(exports, '__esModule', {
|
|
5
|
-
value: true
|
|
6
|
-
})
|
|
7
|
-
exports.bundle = void 0
|
|
8
|
-
const _browserify = _interopRequireDefault(require('browserify'))
|
|
9
|
-
const _gulp = require('gulp')
|
|
10
|
-
const gulpConfig = _interopRequireWildcard(require('../gulp.config.js'))
|
|
11
|
-
const _vinylSourceStream = _interopRequireDefault(require('vinyl-source-stream'))
|
|
12
|
-
function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; let o; let i; const f = { __proto__: null, default: e }; if (e === null || typeof e !== 'object' && typeof e !== 'function') return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f) } for (const t in e) t !== 'default' && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f })(e, t) }
|
|
13
|
-
function _interopRequireDefault (e) { return e && e.__esModule ? e : { default: e } }
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
+
Object.defineProperty(exports, '__esModule', {
|
|
5
|
+
value: true
|
|
6
|
+
})
|
|
7
|
+
exports.bundle = void 0
|
|
8
|
+
const _browserify = _interopRequireDefault(require('browserify'))
|
|
9
|
+
const _gulp = require('gulp')
|
|
10
|
+
const gulpConfig = _interopRequireWildcard(require('../gulp.config.js'))
|
|
11
|
+
const _vinylSourceStream = _interopRequireDefault(require('vinyl-source-stream'))
|
|
12
|
+
function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; let o; let i; const f = { __proto__: null, default: e }; if (e === null || typeof e !== 'object' && typeof e !== 'function') return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f) } for (const t in e) t !== 'default' && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f })(e, t) }
|
|
13
|
+
function _interopRequireDefault (e) { return e && e.__esModule ? e : { default: e } }
|
|
14
14
|
/**
|
|
15
15
|
* Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.
|
|
16
16
|
*
|
|
17
|
+
* browser.name does double duty: it names the output file (browser.name.js) and, via browserify's `standalone`
|
|
18
|
+
* option, is also the name the bundle's exports are exposed under - as a global when loaded with a bare <script>
|
|
19
|
+
* tag, or as the module when required via CommonJS/AMD. Without this, a bundle built from a real entry point (one
|
|
20
|
+
* that actually exports something) builds successfully but exposes nothing a consumer can reach.
|
|
21
|
+
*
|
|
17
22
|
* Two escape hatches from browser.config.json keep an unwanted dependency (or a dependency's dependency) out of the
|
|
18
23
|
* bundle: 'ignore' replaces it with an empty object (safe when your code never actually calls into it - for example
|
|
19
24
|
* a library's default option value you always override with your own) and 'exclude' leaves it out entirely (your
|
|
20
25
|
* code must not require it, or provide it another way, such as a separate script tag).
|
|
21
26
|
* @memberOf module:js-build-tools
|
|
22
27
|
* @returns {stream.Stream}
|
|
23
|
-
*/
|
|
24
|
-
const bundle = () => {
|
|
25
|
-
const bundler = (0, _browserify.default)(gulpConfig.get('dist.main')
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
28
|
+
*/
|
|
29
|
+
const bundle = () => {
|
|
30
|
+
const bundler = (0, _browserify.default)(gulpConfig.get('dist.main'), {
|
|
31
|
+
standalone: gulpConfig.get('browser.name')
|
|
32
|
+
})
|
|
33
|
+
const ignore = gulpConfig.get('browser.ignore')
|
|
34
|
+
const exclude = gulpConfig.get('browser.exclude')
|
|
35
|
+
if (ignore && ignore.length) {
|
|
36
|
+
bundler.ignore(ignore)
|
|
37
|
+
}
|
|
38
|
+
if (exclude && exclude.length) {
|
|
39
|
+
bundler.exclude(exclude)
|
|
40
|
+
}
|
|
41
|
+
return bundler.bundle().pipe((0, _vinylSourceStream.default)(`${gulpConfig.get('browser.name')}.js`)).pipe((0, _gulp.dest)(gulpConfig.get('browser.to')))
|
|
42
|
+
}
|
|
43
|
+
exports.bundle = bundle
|
package/dist/bundle.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("core-js/modules/esnext.weak-map.delete-all.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.bundle=void 0;var _browserify=_interopRequireDefault(require("browserify")),_gulp=require("gulp"),gulpConfig=_interopRequireWildcard(require("../gulp.config.js")),_vinylSourceStream=_interopRequireDefault(require("vinyl-source-stream"));function _interopRequireWildcard(e,r){if("function"==typeof WeakMap)var t=new WeakMap,
|
|
1
|
+
"use strict";require("core-js/modules/esnext.weak-map.delete-all.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.bundle=void 0;var _browserify=_interopRequireDefault(require("browserify")),_gulp=require("gulp"),gulpConfig=_interopRequireWildcard(require("../gulp.config.js")),_vinylSourceStream=_interopRequireDefault(require("vinyl-source-stream"));function _interopRequireWildcard(e,r){if("function"==typeof WeakMap)var t=new WeakMap,n=new WeakMap;return(_interopRequireWildcard=function(e,r){if(!r&&e&&e.__esModule)return e;var u,o,i={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return i;if(u=r?n:t){if(u.has(e))return u.get(e);u.set(e,i)}for(const r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((o=(u=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,r))&&(o.get||o.set)?u(i,r,o):i[r]=e[r]);return i})(e,r)}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const bundle=()=>{const e=(0,_browserify.default)(gulpConfig.get("dist.main"),{standalone:gulpConfig.get("browser.name")}),r=gulpConfig.get("browser.ignore"),t=gulpConfig.get("browser.exclude");return r&&r.length&&e.ignore(r),t&&t.length&&e.exclude(t),e.bundle().pipe((0,_vinylSourceStream.default)(`${gulpConfig.get("browser.name")}.js`)).pipe((0,_gulp.dest)(gulpConfig.get("browser.to")))};exports.bundle=bundle;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.loadImagemin = exports.imagesFor = void 0;
|
|
8
|
-
var _gulpCache = _interopRequireDefault(require("gulp-cache"));
|
|
9
|
-
var _loadPeer = require("./loadPeer.js");
|
|
10
|
-
var _gulp = require("gulp");
|
|
11
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
12
|
-
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
13
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
const installHint = 'Add it to your project with: npm install --save-dev github:jheagle/gulp-imagemin#common-js-compatibility ' + '(the CommonJS-compatible fork - upstream gulp-imagemin is ESM-only and cannot be require()d by this package\'s CommonJS build).';
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.loadImagemin = exports.imagesFor = void 0;
|
|
8
|
+
var _gulpCache = _interopRequireDefault(require("gulp-cache"));
|
|
9
|
+
var _loadPeer = require("./loadPeer.js");
|
|
10
|
+
var _gulp = require("gulp");
|
|
11
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
12
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const installHint = 'Add it to your project with: npm install --save-dev github:jheagle/gulp-imagemin#common-js-compatibility ' + '(the CommonJS-compatible fork - upstream gulp-imagemin is ESM-only and cannot be require()d by this package\'s CommonJS build).';
|
|
16
|
+
|
|
17
17
|
/**
|
|
18
18
|
* Load `gulp-imagemin`, an optional peer dependency: image optimization is off by default and its binary-download
|
|
19
19
|
* dependency chain is heavy, so it is only required once the images task actually runs, and it is resolved from the
|
|
@@ -22,36 +22,36 @@ const installHint = 'Add it to your project with: npm install --save-dev github:
|
|
|
22
22
|
* @param {string} [projectPath=process.cwd()] - The project directory to resolve `gulp-imagemin` from.
|
|
23
23
|
* @returns {Function} The gulp-imagemin plugin factory.
|
|
24
24
|
* @throws {Error} With install instructions when gulp-imagemin is missing or is the ESM-only upstream release.
|
|
25
|
-
*/
|
|
26
|
-
const loadImagemin = (projectPath = process.cwd()) => {
|
|
27
|
-
const loaded = (0, _loadPeer.requirePeer)('gulp-imagemin', {
|
|
28
|
-
task: 'images',
|
|
29
|
-
installHint,
|
|
30
|
-
esmOnlyMessage: `gulp-imagemin could not be loaded because it is ESM-only. ${installHint}`,
|
|
31
|
-
projectPath
|
|
32
|
-
});
|
|
33
|
-
return loaded && (loaded.__esModule || loaded.default) ? loaded.default : loaded;
|
|
34
|
-
};
|
|
35
|
-
|
|
25
|
+
*/
|
|
26
|
+
const loadImagemin = (projectPath = process.cwd()) => {
|
|
27
|
+
const loaded = (0, _loadPeer.requirePeer)('gulp-imagemin', {
|
|
28
|
+
task: 'images',
|
|
29
|
+
installHint,
|
|
30
|
+
esmOnlyMessage: `gulp-imagemin could not be loaded because it is ESM-only. ${installHint}`,
|
|
31
|
+
projectPath
|
|
32
|
+
});
|
|
33
|
+
return loaded && (loaded.__esModule || loaded.default) ? loaded.default : loaded;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
36
|
/**
|
|
37
37
|
* Move and optimize images into the browser directory.
|
|
38
38
|
* @memberOf module:partials
|
|
39
39
|
* @param {string|array} [imageSrc=src/images/pattern]
|
|
40
40
|
* @param {string} [imageDest=dest/image/folder]
|
|
41
41
|
* @return {stream.Stream}
|
|
42
|
-
*/
|
|
43
|
-
exports.loadImagemin = loadImagemin;
|
|
44
|
-
const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpConfig.get('images.to')) => {
|
|
45
|
-
const imagemin = loadImagemin();
|
|
46
|
-
// Gulp 5 reads files as utf8 text unless told otherwise, which corrupts binary images (and makes gulp-cache drop them).
|
|
47
|
-
return (0, _gulp.src)(imageSrc, {
|
|
48
|
-
encoding: false
|
|
49
|
-
}).pipe(
|
|
50
|
-
// Caching images that ran through imagemin
|
|
51
|
-
(0, _gulpCache.default)(imagemin({
|
|
52
|
-
interlaced: true,
|
|
53
|
-
silent: true,
|
|
54
|
-
verbose: false
|
|
55
|
-
}))).pipe((0, _gulp.dest)(imageDest));
|
|
56
|
-
};
|
|
42
|
+
*/
|
|
43
|
+
exports.loadImagemin = loadImagemin;
|
|
44
|
+
const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpConfig.get('images.to')) => {
|
|
45
|
+
const imagemin = loadImagemin();
|
|
46
|
+
// Gulp 5 reads files as utf8 text unless told otherwise, which corrupts binary images (and makes gulp-cache drop them).
|
|
47
|
+
return (0, _gulp.src)(imageSrc, {
|
|
48
|
+
encoding: false
|
|
49
|
+
}).pipe(
|
|
50
|
+
// Caching images that ran through imagemin
|
|
51
|
+
(0, _gulpCache.default)(imagemin({
|
|
52
|
+
interlaced: true,
|
|
53
|
+
silent: true,
|
|
54
|
+
verbose: false
|
|
55
|
+
}))).pipe((0, _gulp.dest)(imageDest));
|
|
56
|
+
};
|
|
57
57
|
exports.imagesFor = imagesFor;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.requirePeer = exports.importPeer = exports.importModule = void 0;
|
|
7
|
-
require("core-js/modules/es.array.includes.js");
|
|
8
|
-
var _nodeModule = require("node:module");
|
|
9
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
-
var _nodeUrl = require("node:url");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
// Several dependencies ship ESM-only (standard, gulp-ts-compile, typedoc), but this package also publishes a CommonJS
|
|
13
|
-
// build (dist/*.js) whose babel transform would turn even a dynamic import() into a require() that cannot load an ES
|
|
14
|
-
// module. Hiding the import() inside a Function constructor keeps it a genuine dynamic import that works from either
|
|
15
|
-
// build, because babel cannot see (and so cannot rewrite) an import expression which only exists as a runtime string.
|
|
16
|
-
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.requirePeer = exports.importPeer = exports.importModule = void 0;
|
|
7
|
+
require("core-js/modules/es.array.includes.js");
|
|
8
|
+
var _nodeModule = require("node:module");
|
|
9
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
+
var _nodeUrl = require("node:url");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
// Several dependencies ship ESM-only (standard, gulp-ts-compile, typedoc), but this package also publishes a CommonJS
|
|
13
|
+
// build (dist/*.js) whose babel transform would turn even a dynamic import() into a require() that cannot load an ES
|
|
14
|
+
// module. Hiding the import() inside a Function constructor keeps it a genuine dynamic import that works from either
|
|
15
|
+
// build, because babel cannot see (and so cannot rewrite) an import expression which only exists as a runtime string.
|
|
16
|
+
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
17
|
+
|
|
18
18
|
/**
|
|
19
19
|
* Import an ES module (or any module) with a real dynamic import(), whichever build (ESM or CommonJS) this runs from.
|
|
20
20
|
* @memberOf module:partials
|
|
21
21
|
* @param {string} specifier - The package name, or the URL of a file.
|
|
22
22
|
* @returns {Promise<Object>} The module namespace.
|
|
23
|
-
*/
|
|
24
|
-
const importModule = specifier => dynamicImport(specifier);
|
|
25
|
-
exports.importModule = importModule;
|
|
26
|
-
const isMissing = (error, name) => error.code === 'MODULE_NOT_FOUND' && error.message.includes(`'${name}'`);
|
|
27
|
-
const notInstalled = (name, {
|
|
28
|
-
task,
|
|
29
|
-
installHint
|
|
30
|
-
}) => new Error(`The ${task} task needs the optional peer dependency ${name}, which is not installed. ${installHint}`);
|
|
31
|
-
|
|
23
|
+
*/
|
|
24
|
+
const importModule = specifier => dynamicImport(specifier);
|
|
25
|
+
exports.importModule = importModule;
|
|
26
|
+
const isMissing = (error, name) => error.code === 'MODULE_NOT_FOUND' && error.message.includes(`'${name}'`);
|
|
27
|
+
const notInstalled = (name, {
|
|
28
|
+
task,
|
|
29
|
+
installHint
|
|
30
|
+
}) => new Error(`The ${task} task needs the optional peer dependency ${name}, which is not installed. ${installHint}`);
|
|
31
|
+
|
|
32
32
|
/**
|
|
33
33
|
* Load an optional peer dependency (one which is only needed once a task runs, so projects which never use that task
|
|
34
34
|
* do not have to install it) with require(), from the project being built rather than from this package. When it is
|
|
@@ -42,29 +42,29 @@ const notInstalled = (name, {
|
|
|
42
42
|
* @param {string} [options.projectPath=process.cwd()] - The folder of the project (which has the package.json) being built.
|
|
43
43
|
* @returns {*} Whatever the package exports.
|
|
44
44
|
* @throws {Error} With install instructions when the package is not installed.
|
|
45
|
-
*/
|
|
46
|
-
const requirePeer = (name, {
|
|
47
|
-
task,
|
|
48
|
-
installHint,
|
|
49
|
-
esmOnlyMessage,
|
|
50
|
-
projectPath = process.cwd()
|
|
51
|
-
}) => {
|
|
52
|
-
try {
|
|
53
|
-
return (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json'))(name);
|
|
54
|
-
} catch (error) {
|
|
55
|
-
if (isMissing(error, name)) {
|
|
56
|
-
throw notInstalled(name, {
|
|
57
|
-
task,
|
|
58
|
-
installHint
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
if (error.code === 'ERR_REQUIRE_ESM' && esmOnlyMessage) {
|
|
62
|
-
throw new Error(esmOnlyMessage);
|
|
63
|
-
}
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
45
|
+
*/
|
|
46
|
+
const requirePeer = (name, {
|
|
47
|
+
task,
|
|
48
|
+
installHint,
|
|
49
|
+
esmOnlyMessage,
|
|
50
|
+
projectPath = process.cwd()
|
|
51
|
+
}) => {
|
|
52
|
+
try {
|
|
53
|
+
return (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json'))(name);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (isMissing(error, name)) {
|
|
56
|
+
throw notInstalled(name, {
|
|
57
|
+
task,
|
|
58
|
+
installHint
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (error.code === 'ERR_REQUIRE_ESM' && esmOnlyMessage) {
|
|
62
|
+
throw new Error(esmOnlyMessage);
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
68
|
/**
|
|
69
69
|
* Import an optional peer dependency which ships ESM-only, from the project being built. See {@link requirePeer}.
|
|
70
70
|
* @memberOf module:partials
|
|
@@ -75,25 +75,25 @@ const requirePeer = (name, {
|
|
|
75
75
|
* @param {string} [options.projectPath=process.cwd()] - The folder of the project (which has the package.json) being built.
|
|
76
76
|
* @returns {Promise<Object>} The module namespace.
|
|
77
77
|
* @throws {Error} With install instructions when the package is not installed.
|
|
78
|
-
*/
|
|
79
|
-
exports.requirePeer = requirePeer;
|
|
80
|
-
const importPeer = async (name, {
|
|
81
|
-
task,
|
|
82
|
-
installHint,
|
|
83
|
-
projectPath = process.cwd()
|
|
84
|
-
}) => {
|
|
85
|
-
let resolved;
|
|
86
|
-
try {
|
|
87
|
-
resolved = (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json')).resolve(name);
|
|
88
|
-
} catch (error) {
|
|
89
|
-
if (isMissing(error, name)) {
|
|
90
|
-
throw notInstalled(name, {
|
|
91
|
-
task,
|
|
92
|
-
installHint
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
return importModule((0, _nodeUrl.pathToFileURL)(resolved).href);
|
|
98
|
-
};
|
|
78
|
+
*/
|
|
79
|
+
exports.requirePeer = requirePeer;
|
|
80
|
+
const importPeer = async (name, {
|
|
81
|
+
task,
|
|
82
|
+
installHint,
|
|
83
|
+
projectPath = process.cwd()
|
|
84
|
+
}) => {
|
|
85
|
+
let resolved;
|
|
86
|
+
try {
|
|
87
|
+
resolved = (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json')).resolve(name);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (isMissing(error, name)) {
|
|
90
|
+
throw notInstalled(name, {
|
|
91
|
+
task,
|
|
92
|
+
installHint
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
return importModule((0, _nodeUrl.pathToFileURL)(resolved).href);
|
|
98
|
+
};
|
|
99
99
|
exports.importPeer = importPeer;
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.standardLint = void 0;
|
|
7
|
-
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
-
require("core-js/modules/esnext.iterator.for-each.js");
|
|
9
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
-
var _through = _interopRequireDefault(require("through2"));
|
|
11
|
-
var _loadPeer = require("./loadPeer.js");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
// `standard` (17+) ships ESM-only, see importModule for how it is imported.
|
|
14
|
-
const importStandard = () => (0, _loadPeer.importModule)('standard');
|
|
15
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.standardLint = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
9
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
+
var _through = _interopRequireDefault(require("through2"));
|
|
11
|
+
var _loadPeer = require("./loadPeer.js");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
// `standard` (17+) ships ESM-only, see importModule for how it is imported.
|
|
14
|
+
const importStandard = () => (0, _loadPeer.importModule)('standard');
|
|
15
|
+
|
|
16
16
|
/**
|
|
17
17
|
* Print a file's lint messages, if it has any.
|
|
18
18
|
* @memberOf module:partials
|
|
19
19
|
* @param {import('vinyl')} file
|
|
20
20
|
* @param {{messages: Array<{line: number, column: number, message: string}>, errorCount: number, warningCount: number}} result
|
|
21
21
|
* @returns {undefined}
|
|
22
|
-
*/
|
|
23
|
-
const printFileReport = (file, result) => {
|
|
24
|
-
if (!result.messages.length) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
console.log(_nodePath.default.relative(file.cwd, file.path));
|
|
28
|
-
result.messages.forEach(({
|
|
29
|
-
line,
|
|
30
|
-
column,
|
|
31
|
-
message
|
|
32
|
-
}) => console.log(`line ${line}:${column}\t${message}`));
|
|
33
|
-
console.log(`✖ ${result.errorCount} error\t⚠ ${result.warningCount} warning\n`);
|
|
34
|
-
};
|
|
35
|
-
|
|
22
|
+
*/
|
|
23
|
+
const printFileReport = (file, result) => {
|
|
24
|
+
if (!result.messages.length) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
console.log(_nodePath.default.relative(file.cwd, file.path));
|
|
28
|
+
result.messages.forEach(({
|
|
29
|
+
line,
|
|
30
|
+
column,
|
|
31
|
+
message
|
|
32
|
+
}) => console.log(`line ${line}:${column}\t${message}`));
|
|
33
|
+
console.log(`✖ ${result.errorCount} error\t⚠ ${result.warningCount} warning\n`);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
36
|
/**
|
|
37
37
|
* Lint every file streaming through with JavaScript Standard Style and, unless `fix` is false, apply the automatic
|
|
38
38
|
* fixes to the file's contents so a following `dest()` writes the fixed version. Remaining problems are printed
|
|
@@ -47,48 +47,48 @@ const printFileReport = (file, result) => {
|
|
|
47
47
|
* should never need to pass this - it exists so tests can supply a stand-in, since this project's
|
|
48
48
|
* CommonJS-transform-based Jest setup cannot execute a real dynamic import() of an ES module.
|
|
49
49
|
* @returns {import('stream').Transform}
|
|
50
|
-
*/
|
|
51
|
-
const standardLint = ({
|
|
52
|
-
fix = true
|
|
53
|
-
} = {}, loadStandard = () => importStandard().then(({
|
|
54
|
-
default: standard
|
|
55
|
-
}) => standard)) => {
|
|
56
|
-
const totals = {
|
|
57
|
-
errors: 0,
|
|
58
|
-
warnings: 0
|
|
59
|
-
};
|
|
60
|
-
return _through.default.obj(function (file, enc, callback) {
|
|
61
|
-
if (file.isNull()) {
|
|
62
|
-
callback(null, file);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (file.isStream()) {
|
|
66
|
-
callback(new Error('standardLint: streaming file contents are not supported.'));
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
loadStandard().then(standard => standard.lintText(file.contents.toString(), {
|
|
70
|
-
filename: file.path,
|
|
71
|
-
cwd: file.cwd,
|
|
72
|
-
fix
|
|
73
|
-
})).then(results => {
|
|
74
|
-
// No result at all means the file is ignored by the project's Standard configuration.
|
|
75
|
-
const [result] = results;
|
|
76
|
-
if (result) {
|
|
77
|
-
if (typeof result.output === 'string') {
|
|
78
|
-
file.contents = Buffer.from(result.output);
|
|
79
|
-
}
|
|
80
|
-
totals.errors += result.errorCount;
|
|
81
|
-
totals.warnings += result.warningCount;
|
|
82
|
-
printFileReport(file, result);
|
|
83
|
-
}
|
|
84
|
-
callback(null, file);
|
|
85
|
-
}, callback);
|
|
86
|
-
}, function (callback) {
|
|
87
|
-
console.log('Standard linter results');
|
|
88
|
-
console.log('======================================');
|
|
89
|
-
console.log(`✖ Errors total: ${totals.errors}`);
|
|
90
|
-
console.log(`⚠ Warnings total: ${totals.warnings}\n`);
|
|
91
|
-
callback();
|
|
92
|
-
});
|
|
93
|
-
};
|
|
50
|
+
*/
|
|
51
|
+
const standardLint = ({
|
|
52
|
+
fix = true
|
|
53
|
+
} = {}, loadStandard = () => importStandard().then(({
|
|
54
|
+
default: standard
|
|
55
|
+
}) => standard)) => {
|
|
56
|
+
const totals = {
|
|
57
|
+
errors: 0,
|
|
58
|
+
warnings: 0
|
|
59
|
+
};
|
|
60
|
+
return _through.default.obj(function (file, enc, callback) {
|
|
61
|
+
if (file.isNull()) {
|
|
62
|
+
callback(null, file);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (file.isStream()) {
|
|
66
|
+
callback(new Error('standardLint: streaming file contents are not supported.'));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
loadStandard().then(standard => standard.lintText(file.contents.toString(), {
|
|
70
|
+
filename: file.path,
|
|
71
|
+
cwd: file.cwd,
|
|
72
|
+
fix
|
|
73
|
+
})).then(results => {
|
|
74
|
+
// No result at all means the file is ignored by the project's Standard configuration.
|
|
75
|
+
const [result] = results;
|
|
76
|
+
if (result) {
|
|
77
|
+
if (typeof result.output === 'string') {
|
|
78
|
+
file.contents = Buffer.from(result.output);
|
|
79
|
+
}
|
|
80
|
+
totals.errors += result.errorCount;
|
|
81
|
+
totals.warnings += result.warningCount;
|
|
82
|
+
printFileReport(file, result);
|
|
83
|
+
}
|
|
84
|
+
callback(null, file);
|
|
85
|
+
}, callback);
|
|
86
|
+
}, function (callback) {
|
|
87
|
+
console.log('Standard linter results');
|
|
88
|
+
console.log('======================================');
|
|
89
|
+
console.log(`✖ Errors total: ${totals.errors}`);
|
|
90
|
+
console.log(`⚠ Warnings total: ${totals.warnings}\n`);
|
|
91
|
+
callback();
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
94
|
exports.standardLint = standardLint;
|
package/dist/partials/tsFor.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.tsFor = exports.loadTypescript = void 0;
|
|
8
|
-
var _gulp = require("gulp");
|
|
9
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
-
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
11
|
-
var _loadPeer = require("./loadPeer.js");
|
|
12
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
// gulp-ts-compile ships ESM-only (no CJS build - see its own package.json), see importModule for how it is imported.
|
|
15
|
-
const importGulpTsCompile = () => (0, _loadPeer.importModule)('gulp-ts-compile');
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.tsFor = exports.loadTypescript = void 0;
|
|
8
|
+
var _gulp = require("gulp");
|
|
9
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
11
|
+
var _loadPeer = require("./loadPeer.js");
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
// gulp-ts-compile ships ESM-only (no CJS build - see its own package.json), see importModule for how it is imported.
|
|
15
|
+
const importGulpTsCompile = () => (0, _loadPeer.importModule)('gulp-ts-compile');
|
|
16
|
+
|
|
17
17
|
/**
|
|
18
18
|
* Wrap a stream in a promise that resolves once it finishes writing.
|
|
19
19
|
* @memberOf module:partials
|
|
20
20
|
* @param {import('node:stream').Stream} stream
|
|
21
21
|
* @returns {Promise<void>}
|
|
22
|
-
*/
|
|
23
|
-
const installHint = 'Install it in your project with: npm install --save-dev typescript';
|
|
24
|
-
|
|
22
|
+
*/
|
|
23
|
+
const installHint = 'Install it in your project with: npm install --save-dev typescript';
|
|
24
|
+
|
|
25
25
|
/**
|
|
26
26
|
* Load the project's own copy of TypeScript (an optional peer dependency, only needed when the typescript task is
|
|
27
27
|
* enabled) from the project being built, so projects which do not use TypeScript never need it installed.
|
|
@@ -29,18 +29,18 @@ const installHint = 'Install it in your project with: npm install --save-dev typ
|
|
|
29
29
|
* @param {string} [projectPath=process.cwd()] The folder of the project (which has the package.json) being built.
|
|
30
30
|
* @returns {Object} The TypeScript compiler API module.
|
|
31
31
|
* @throws {Error} With install instructions when typescript is not installed.
|
|
32
|
-
*/
|
|
33
|
-
const loadTypescript = (projectPath = process.cwd()) => (0, _loadPeer.requirePeer)('typescript', {
|
|
34
|
-
task: 'typescript',
|
|
35
|
-
installHint,
|
|
36
|
-
projectPath
|
|
37
|
-
});
|
|
38
|
-
exports.loadTypescript = loadTypescript;
|
|
39
|
-
const streamToPromise = stream => new Promise((resolve, reject) => {
|
|
40
|
-
stream.on('finish', resolve);
|
|
41
|
-
stream.on('error', reject);
|
|
42
|
-
});
|
|
43
|
-
|
|
32
|
+
*/
|
|
33
|
+
const loadTypescript = (projectPath = process.cwd()) => (0, _loadPeer.requirePeer)('typescript', {
|
|
34
|
+
task: 'typescript',
|
|
35
|
+
installHint,
|
|
36
|
+
projectPath
|
|
37
|
+
});
|
|
38
|
+
exports.loadTypescript = loadTypescript;
|
|
39
|
+
const streamToPromise = stream => new Promise((resolve, reject) => {
|
|
40
|
+
stream.on('finish', resolve);
|
|
41
|
+
stream.on('error', reject);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
44
|
/**
|
|
45
45
|
* Read a tsconfig.json file into real typescript.CompilerOptions values, using only TypeScript's stable, current,
|
|
46
46
|
* public config-reading API (the same one `tsc --project` itself uses internally) - never
|
|
@@ -49,13 +49,13 @@ const streamToPromise = stream => new Promise((resolve, reject) => {
|
|
|
49
49
|
* @memberOf module:partials
|
|
50
50
|
* @param {string} configPath - Path to a tsconfig.json file.
|
|
51
51
|
* @returns {import('typescript').CompilerOptions}
|
|
52
|
-
*/
|
|
53
|
-
const readCompilerOptions = (ts, configPath) => {
|
|
54
|
-
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
55
|
-
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, _nodePath.default.dirname(configPath));
|
|
56
|
-
return parsedConfig.options;
|
|
57
|
-
};
|
|
58
|
-
|
|
52
|
+
*/
|
|
53
|
+
const readCompilerOptions = (ts, configPath) => {
|
|
54
|
+
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
55
|
+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, _nodePath.default.dirname(configPath));
|
|
56
|
+
return parsedConfig.options;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
59
|
/**
|
|
60
60
|
* Starting at the source directory, find all the ts files and convert them into the distribution directory.
|
|
61
61
|
* @memberOf module:partials
|
|
@@ -68,36 +68,36 @@ const readCompilerOptions = (ts, configPath) => {
|
|
|
68
68
|
* suite already covers real TypeScript-compile correctness - this function's own tests only need to verify its
|
|
69
69
|
* config resolution and stream wiring.
|
|
70
70
|
* @returns {Function}
|
|
71
|
-
*/
|
|
72
|
-
const tsFor = (srcPath = gulpConfig.get('typescript.from'), distPath = gulpConfig.get('typescript.to'), loadTsCompile = () => importGulpTsCompile().then(({
|
|
73
|
-
default: tsCompile
|
|
74
|
-
}) => tsCompile)) => {
|
|
75
|
-
if (gulpConfig.get('typescript.enabled') === false) {
|
|
76
|
-
return () => {};
|
|
77
|
-
}
|
|
78
|
-
const ts = loadTypescript();
|
|
79
|
-
const configPath = gulpConfig.get('typescript.config');
|
|
80
|
-
// When no tsconfig.json is configured, target/module are pinned explicitly rather than left for TypeScript's
|
|
81
|
-
// own compiler defaults - those defaults have already shifted once across a TypeScript version bump in this
|
|
82
|
-
// project's own history (silently changing whether output keeps `const`/`let` or downlevels to `var`), and
|
|
83
|
-
// pinning them keeps this task's output stable across future TypeScript upgrades too. ES5/CommonJS matches
|
|
84
|
-
// what the downstream babel/browserify bundling pipeline has always assumed it receives.
|
|
85
|
-
const compilerOptions = configPath ? readCompilerOptions(ts, configPath) : {
|
|
86
|
-
declaration: true,
|
|
87
|
-
target: ts.ScriptTarget.ES5,
|
|
88
|
-
module: ts.ModuleKind.CommonJS,
|
|
89
|
-
esModuleInterop: false
|
|
90
|
-
};
|
|
91
|
-
// Accepts gulp's own callback-style task convention (an optional `done`, called once finished) rather than
|
|
92
|
-
// just returning a Promise, since callers may invoke the returned function directly with a callback instead
|
|
93
|
-
// of relying on gulp's own runner to observe a returned Promise.
|
|
94
|
-
return done => {
|
|
95
|
-
const compile = async () => {
|
|
96
|
-
const tsCompile = await loadTsCompile();
|
|
97
|
-
const tsResult = (0, _gulp.src)(srcPath).pipe(tsCompile(compilerOptions));
|
|
98
|
-
await Promise.all([streamToPromise(tsResult.dts.pipe((0, _gulp.dest)(distPath))), streamToPromise(tsResult.js.pipe((0, _gulp.dest)(distPath)))]);
|
|
99
|
-
};
|
|
100
|
-
return typeof done === 'function' ? compile().then(() => done(), done) : compile();
|
|
101
|
-
};
|
|
102
|
-
};
|
|
71
|
+
*/
|
|
72
|
+
const tsFor = (srcPath = gulpConfig.get('typescript.from'), distPath = gulpConfig.get('typescript.to'), loadTsCompile = () => importGulpTsCompile().then(({
|
|
73
|
+
default: tsCompile
|
|
74
|
+
}) => tsCompile)) => {
|
|
75
|
+
if (gulpConfig.get('typescript.enabled') === false) {
|
|
76
|
+
return () => {};
|
|
77
|
+
}
|
|
78
|
+
const ts = loadTypescript();
|
|
79
|
+
const configPath = gulpConfig.get('typescript.config');
|
|
80
|
+
// When no tsconfig.json is configured, target/module are pinned explicitly rather than left for TypeScript's
|
|
81
|
+
// own compiler defaults - those defaults have already shifted once across a TypeScript version bump in this
|
|
82
|
+
// project's own history (silently changing whether output keeps `const`/`let` or downlevels to `var`), and
|
|
83
|
+
// pinning them keeps this task's output stable across future TypeScript upgrades too. ES5/CommonJS matches
|
|
84
|
+
// what the downstream babel/browserify bundling pipeline has always assumed it receives.
|
|
85
|
+
const compilerOptions = configPath ? readCompilerOptions(ts, configPath) : {
|
|
86
|
+
declaration: true,
|
|
87
|
+
target: ts.ScriptTarget.ES5,
|
|
88
|
+
module: ts.ModuleKind.CommonJS,
|
|
89
|
+
esModuleInterop: false
|
|
90
|
+
};
|
|
91
|
+
// Accepts gulp's own callback-style task convention (an optional `done`, called once finished) rather than
|
|
92
|
+
// just returning a Promise, since callers may invoke the returned function directly with a callback instead
|
|
93
|
+
// of relying on gulp's own runner to observe a returned Promise.
|
|
94
|
+
return done => {
|
|
95
|
+
const compile = async () => {
|
|
96
|
+
const tsCompile = await loadTsCompile();
|
|
97
|
+
const tsResult = (0, _gulp.src)(srcPath).pipe(tsCompile(compilerOptions));
|
|
98
|
+
await Promise.all([streamToPromise(tsResult.dts.pipe((0, _gulp.dest)(distPath))), streamToPromise(tsResult.js.pipe((0, _gulp.dest)(distPath)))]);
|
|
99
|
+
};
|
|
100
|
+
return typeof done === 'function' ? compile().then(() => done(), done) : compile();
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
103
|
exports.tsFor = tsFor;
|
package/dist/partials.js
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
Object.defineProperty(exports, 'addToReadme', {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _addToReadme.addToReadme
|
|
10
|
-
}
|
|
11
|
-
})
|
|
12
|
-
Object.defineProperty(exports, 'beginWatcher', {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _beginWatcher.beginWatcher
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
Object.defineProperty(exports, 'clean', {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _clean.clean
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
Object.defineProperty(exports, 'copyFor', {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _copyFor.copyFor
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
Object.defineProperty(exports, 'distFor', {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _distFor.distFor
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
Object.defineProperty(exports, 'distForSrc', {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _distForSrc.distForSrc
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
Object.defineProperty(exports, 'distSeries', {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _distSeries.distSeries
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
Object.defineProperty(exports, 'imagesFor', {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return _imagesFor.imagesFor
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
Object.defineProperty(exports, 'importModule', {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _loadPeer.importModule
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
Object.defineProperty(exports, 'importPeer', {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function () {
|
|
63
|
-
return _loadPeer.importPeer
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
Object.defineProperty(exports, 'minifyFor', {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function () {
|
|
69
|
-
return _minifyFor.minifyFor
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
Object.defineProperty(exports, 'readmeTemplate', {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function () {
|
|
75
|
-
return _readmeTemplate.readmeTemplate
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
Object.defineProperty(exports, 'removeDirectory', {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
get: function () {
|
|
81
|
-
return _removeDirectory.removeDirectory
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
Object.defineProperty(exports, 'requirePeer', {
|
|
85
|
-
enumerable: true,
|
|
86
|
-
get: function () {
|
|
87
|
-
return _loadPeer.requirePeer
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
Object.defineProperty(exports, 'runOnChange', {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
get: function () {
|
|
93
|
-
return _runOnChange.runOnChange
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
Object.defineProperty(exports, 'sassFor', {
|
|
97
|
-
enumerable: true,
|
|
98
|
-
get: function () {
|
|
99
|
-
return _sassFor.sassFor
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
Object.defineProperty(exports, 'standardLint', {
|
|
103
|
-
enumerable: true,
|
|
104
|
-
get: function () {
|
|
105
|
-
return _standardLint.standardLint
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
Object.defineProperty(exports, 'tsFor', {
|
|
109
|
-
enumerable: true,
|
|
110
|
-
get: function () {
|
|
111
|
-
return _tsFor.tsFor
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
Object.defineProperty(exports, 'typeDocsFor', {
|
|
115
|
-
enumerable: true,
|
|
116
|
-
get: function () {
|
|
117
|
-
return _typeDocsFor.typeDocsFor
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
var _addToReadme = require('./partials/addToReadme.js')
|
|
121
|
-
var _beginWatcher = require('./partials/beginWatcher.js')
|
|
122
|
-
var _clean = require('./partials/clean.js')
|
|
123
|
-
var _copyFor = require('./partials/copyFor.js')
|
|
124
|
-
var _distFor = require('./partials/distFor.js')
|
|
125
|
-
var _distForSrc = require('./partials/distForSrc.js')
|
|
126
|
-
var _distSeries = require('./partials/distSeries.js')
|
|
127
|
-
var _imagesFor = require('./partials/imagesFor.js')
|
|
128
|
-
var _loadPeer = require('./partials/loadPeer.js')
|
|
129
|
-
var _minifyFor = require('./partials/minifyFor.js')
|
|
130
|
-
var _readmeTemplate = require('./partials/readmeTemplate.js')
|
|
131
|
-
var _removeDirectory = require('./partials/removeDirectory.js')
|
|
132
|
-
var _runOnChange = require('./partials/runOnChange.js')
|
|
133
|
-
var _sassFor = require('./partials/sassFor.js')
|
|
134
|
-
var _standardLint = require('./partials/standardLint.js')
|
|
135
|
-
var _tsFor = require('./partials/tsFor.js')
|
|
136
|
-
var _typeDocsFor = require('./partials/typeDocsFor.js')
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
Object.defineProperty(exports, 'addToReadme', {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _addToReadme.addToReadme
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
Object.defineProperty(exports, 'beginWatcher', {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _beginWatcher.beginWatcher
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
Object.defineProperty(exports, 'clean', {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _clean.clean
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
Object.defineProperty(exports, 'copyFor', {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _copyFor.copyFor
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
Object.defineProperty(exports, 'distFor', {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _distFor.distFor
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
Object.defineProperty(exports, 'distForSrc', {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _distForSrc.distForSrc
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
Object.defineProperty(exports, 'distSeries', {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _distSeries.distSeries
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
Object.defineProperty(exports, 'imagesFor', {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _imagesFor.imagesFor
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
Object.defineProperty(exports, 'importModule', {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _loadPeer.importModule
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
Object.defineProperty(exports, 'importPeer', {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _loadPeer.importPeer
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
Object.defineProperty(exports, 'minifyFor', {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _minifyFor.minifyFor
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
Object.defineProperty(exports, 'readmeTemplate', {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _readmeTemplate.readmeTemplate
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
Object.defineProperty(exports, 'removeDirectory', {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _removeDirectory.removeDirectory
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
Object.defineProperty(exports, 'requirePeer', {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _loadPeer.requirePeer
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
Object.defineProperty(exports, 'runOnChange', {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () {
|
|
93
|
+
return _runOnChange.runOnChange
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
Object.defineProperty(exports, 'sassFor', {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _sassFor.sassFor
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
Object.defineProperty(exports, 'standardLint', {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () {
|
|
105
|
+
return _standardLint.standardLint
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
Object.defineProperty(exports, 'tsFor', {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () {
|
|
111
|
+
return _tsFor.tsFor
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
Object.defineProperty(exports, 'typeDocsFor', {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function () {
|
|
117
|
+
return _typeDocsFor.typeDocsFor
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
var _addToReadme = require('./partials/addToReadme.js')
|
|
121
|
+
var _beginWatcher = require('./partials/beginWatcher.js')
|
|
122
|
+
var _clean = require('./partials/clean.js')
|
|
123
|
+
var _copyFor = require('./partials/copyFor.js')
|
|
124
|
+
var _distFor = require('./partials/distFor.js')
|
|
125
|
+
var _distForSrc = require('./partials/distForSrc.js')
|
|
126
|
+
var _distSeries = require('./partials/distSeries.js')
|
|
127
|
+
var _imagesFor = require('./partials/imagesFor.js')
|
|
128
|
+
var _loadPeer = require('./partials/loadPeer.js')
|
|
129
|
+
var _minifyFor = require('./partials/minifyFor.js')
|
|
130
|
+
var _readmeTemplate = require('./partials/readmeTemplate.js')
|
|
131
|
+
var _removeDirectory = require('./partials/removeDirectory.js')
|
|
132
|
+
var _runOnChange = require('./partials/runOnChange.js')
|
|
133
|
+
var _sassFor = require('./partials/sassFor.js')
|
|
134
|
+
var _standardLint = require('./partials/standardLint.js')
|
|
135
|
+
var _tsFor = require('./partials/tsFor.js')
|
|
136
|
+
var _typeDocsFor = require('./partials/typeDocsFor.js')
|
package/dist/typeDocs.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.typeDocs = void 0
|
|
7
|
-
const _typeDocsFor = require('./partials/typeDocsFor.js')
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.typeDocs = void 0
|
|
7
|
+
const _typeDocsFor = require('./partials/typeDocsFor.js')
|
|
8
8
|
/**
|
|
9
9
|
* Generate the HTML documentation of a TypeScript project from its source, with the modules mirroring the source
|
|
10
10
|
* folders. Turn it on with docs.enabled, see {@link module:partials.typeDocsFor}.
|
|
11
11
|
* @memberOf module:js-build-tools
|
|
12
12
|
* @returns {Function}
|
|
13
|
-
*/
|
|
14
|
-
const typeDocs = exports.typeDocs = (0, _typeDocsFor.typeDocsFor)()
|
|
13
|
+
*/
|
|
14
|
+
const typeDocs = exports.typeDocs = (0, _typeDocsFor.typeDocsFor)()
|
package/functions/bundle.mjs
CHANGED
|
@@ -6,6 +6,11 @@ import source from 'vinyl-source-stream'
|
|
|
6
6
|
/**
|
|
7
7
|
* Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.
|
|
8
8
|
*
|
|
9
|
+
* browser.name does double duty: it names the output file (browser.name.js) and, via browserify's `standalone`
|
|
10
|
+
* option, is also the name the bundle's exports are exposed under - as a global when loaded with a bare <script>
|
|
11
|
+
* tag, or as the module when required via CommonJS/AMD. Without this, a bundle built from a real entry point (one
|
|
12
|
+
* that actually exports something) builds successfully but exposes nothing a consumer can reach.
|
|
13
|
+
*
|
|
9
14
|
* Two escape hatches from browser.config.json keep an unwanted dependency (or a dependency's dependency) out of the
|
|
10
15
|
* bundle: 'ignore' replaces it with an empty object (safe when your code never actually calls into it - for example
|
|
11
16
|
* a library's default option value you always override with your own) and 'exclude' leaves it out entirely (your
|
|
@@ -14,7 +19,7 @@ import source from 'vinyl-source-stream'
|
|
|
14
19
|
* @returns {stream.Stream}
|
|
15
20
|
*/
|
|
16
21
|
export const bundle = () => {
|
|
17
|
-
const bundler = browserify(gulpConfig.get('dist.main'))
|
|
22
|
+
const bundler = browserify(gulpConfig.get('dist.main'), { standalone: gulpConfig.get('browser.name') })
|
|
18
23
|
const ignore = gulpConfig.get('browser.ignore')
|
|
19
24
|
const exclude = gulpConfig.get('browser.exclude')
|
|
20
25
|
if (ignore && ignore.length) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
2
3
|
import * as setUp from './test-helpers/setUp.mjs'
|
|
3
4
|
import { bundle } from './bundle.mjs'
|
|
4
5
|
import { countMatches } from 'test-filesystem'
|
|
@@ -66,6 +67,25 @@ describe('bundle', () => {
|
|
|
66
67
|
done()
|
|
67
68
|
})
|
|
68
69
|
})
|
|
70
|
+
|
|
71
|
+
test('exposes browser.name as the standalone export, reachable by a real consumer', done => {
|
|
72
|
+
const destPath = gulpConfig.get('browser.to')
|
|
73
|
+
const bundledFile = `${destPath}/${gulpConfig.get('browser.name')}.js`
|
|
74
|
+
expect.assertions(2)
|
|
75
|
+
bundle()
|
|
76
|
+
.on('finish', () => {
|
|
77
|
+
// A UMD bundle (browserify's `standalone` option) resolves to its CommonJS branch when
|
|
78
|
+
// required like this, and to a `window.<browser.name>` global when loaded via a bare
|
|
79
|
+
// <script> tag in a real browser - both paths hit the same exported value.
|
|
80
|
+
const resolved = path.resolve(bundledFile)
|
|
81
|
+
delete require.cache[resolved]
|
|
82
|
+
const loaded = require(resolved)
|
|
83
|
+
expect(typeof loaded.file1).toBe('function')
|
|
84
|
+
expect(typeof loaded.file2).toBe('function')
|
|
85
|
+
done()
|
|
86
|
+
})
|
|
87
|
+
.on('error', error => done(error))
|
|
88
|
+
})
|
|
69
89
|
})
|
|
70
90
|
|
|
71
91
|
describe('bundle ignore / exclude', () => {
|