js-build-tools 6.3.0 → 6.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/README.md +10 -3
- package/dist/lint.js +17 -0
- package/dist/lint.min.js +1 -0
- package/dist/partials/imagesFor.js +42 -43
- package/dist/partials/jsdocDocsFor.js +5 -3
- package/dist/partials/lintSource.js +41 -0
- package/dist/partials/loadPeer.js +71 -70
- package/dist/partials/minifyFor.js +16 -16
- package/dist/partials/neostandardLint.js +130 -122
- package/dist/partials.js +176 -169
- package/dist/partials.min.js +1 -1
- package/dist/sourceLint.js +11 -27
- package/dist/sourceLint.min.js +1 -1
- package/dist/test-helpers/isolateGulpCache.js +25 -0
- package/dist/utilities/dotGet.js +46 -46
- package/dist/utilities/dotNotate.js +48 -48
- package/dist/utilities/dotSet.js +37 -37
- package/functions/build.test.mjs +17 -7
- package/functions/bundle.test.mjs +0 -1
- package/functions/images.test.mjs +4 -1
- package/functions/lint.mjs +9 -0
- package/functions/partials/addToReadme.test.mjs +2 -1
- package/functions/partials/imagesFor.mjs +0 -1
- package/functions/partials/imagesFor.test.mjs +5 -2
- package/functions/partials/jsdocDocsFor.mjs +11 -3
- package/functions/partials/jsdocDocsFor.test.mjs +5 -2
- package/functions/partials/lintSource.mjs +27 -0
- package/functions/partials/loadPeer.mjs +1 -0
- package/functions/partials/loadPlaywright.test.mjs +1 -2
- package/functions/partials/minifyFor.mjs +1 -1
- package/functions/partials/neostandardLint.mjs +9 -2
- package/functions/partials/neostandardLint.test.mjs +14 -0
- package/functions/partials/runOnChange.test.mjs +5 -4
- package/functions/partials/tsFor.test.mjs +1 -0
- package/functions/partials.mjs +1 -0
- package/functions/partials.test.mjs +1 -1
- package/functions/sourceLint.mjs +4 -15
- package/functions/sourceLint.test.mjs +49 -0
- package/functions/test-helpers/isolateGulpCache.mjs +16 -0
- package/functions/test-helpers/setUp.mjs +7 -7
- package/functions/testFull.test.mjs +1 -1
- package/functions/testQuick.test.mjs +1 -1
- package/functions/utilities/convertMjsFilesForDocs.test.mjs +1 -0
- package/functions/utilities/dotGet.mjs +2 -2
- package/functions/utilities/dotNotate.mjs +2 -2
- package/functions/utilities/dotNotate.test.mjs +7 -0
- package/functions/utilities/dotSet.mjs +1 -1
- package/gulpfile.base.mjs +1 -0
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -592,8 +592,8 @@ using `<script type="module">`, which no DOM-simulation library executes at all)
|
|
|
592
592
|
`playwright` is an optional peer dependency, install it in your project with `npm install --save-dev playwright`,
|
|
593
593
|
then fetch a real browser binary once per machine (not per project) with `npx playwright install chromium` - if
|
|
594
594
|
that fails with "Playwright does not support chromium on <your distro>", your OS is too old for the current
|
|
595
|
-
release; either upgrade it or pin an older `playwright` version known to still support it (confirmed: `1.
|
|
596
|
-
still installs and runs real headless Chromium on Ubuntu 20.04
|
|
595
|
+
release; either upgrade it or pin an older `playwright` version known to still support it (confirmed: `1.62.1`
|
|
596
|
+
is the newest release that still installs and runs real headless Chromium on Ubuntu 20.04).
|
|
597
597
|
|
|
598
598
|
```js
|
|
599
599
|
const { launchBrowser, serveStatic } = require('js-build-tools').partials
|
|
@@ -689,6 +689,7 @@ Export these functions to your own project to customize your build pipeline.
|
|
|
689
689
|
* [.testQuick()](#module_js-build-tools.testQuick) ⇒ <code>Promise.<\*></code>
|
|
690
690
|
* [.testFull()](#module_js-build-tools.testFull) ⇒ <code>Promise.<\*></code>
|
|
691
691
|
* [.sourceLint()](#module_js-build-tools.sourceLint) ⇒ <code>\*</code>
|
|
692
|
+
* [.lint()](#module_js-build-tools.lint) ⇒ <code>\*</code>
|
|
692
693
|
* [.images()](#module_js-build-tools.images) ⇒ <code>stream.Stream</code>
|
|
693
694
|
* [.docs([done])](#module_js-build-tools.docs) ⇒ <code>\*</code>
|
|
694
695
|
* [.distMinify()](#module_js-build-tools.distMinify) ⇒ <code>\*</code>
|
|
@@ -751,7 +752,13 @@ Run all tests with jest.
|
|
|
751
752
|
<a name="module_js-build-tools.sourceLint"></a>
|
|
752
753
|
|
|
753
754
|
### js-build-tools.sourceLint() ⇒ <code>\*</code>
|
|
754
|
-
Applies neostandard linting (js-build-tools' chosen style) to the real, hand-written source - not the compiled
|
|
755
|
+
Applies neostandard linting (js-build-tools' chosen style) to the real, hand-written source - not the compiled
|
|
756
|
+
|
|
757
|
+
**Kind**: static method of [<code>js-build-tools</code>](#module_js-build-tools)
|
|
758
|
+
<a name="module_js-build-tools.lint"></a>
|
|
759
|
+
|
|
760
|
+
### js-build-tools.lint() ⇒ <code>\*</code>
|
|
761
|
+
The standalone lint command (`gulp lint`, or `npm run lint`): the same linting and fixing as sourceLint, but it
|
|
755
762
|
|
|
756
763
|
**Kind**: static method of [<code>js-build-tools</code>](#module_js-build-tools)
|
|
757
764
|
<a name="module_js-build-tools.images"></a>
|
package/dist/lint.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.lint = void 0;
|
|
7
|
+
var _lintSource = require("./partials/lintSource.js");
|
|
8
|
+
/**
|
|
9
|
+
* The standalone lint command (`gulp lint`, or `npm run lint`): the same linting and fixing as sourceLint, but it
|
|
10
|
+
* fails (exits non-zero) when any errors remain that neostandard could not fix automatically.
|
|
11
|
+
* @memberOf module:js-build-tools
|
|
12
|
+
* @returns {*}
|
|
13
|
+
*/
|
|
14
|
+
const lint = () => (0, _lintSource.lintSource)({
|
|
15
|
+
failOnError: true
|
|
16
|
+
});
|
|
17
|
+
exports.lint = lint;
|
package/dist/lint.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.lint=void 0;var _lintSource=require("./partials/lintSource.js");const lint=()=>(0,_lintSource.lintSource)({failOnError:!0});exports.lint=lint;
|
|
@@ -1,20 +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
|
|
12
|
-
var
|
|
13
|
-
var cache;
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
12
|
+
var cache;
|
|
13
|
+
function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
|
|
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
|
+
|
|
18
17
|
/**
|
|
19
18
|
* Load `gulp-imagemin`, an optional peer dependency: image optimization is off by default and its binary-download
|
|
20
19
|
* dependency chain is heavy, so it is only required once the images task actually runs, and it is resolved from the
|
|
@@ -23,36 +22,36 @@ const installHint = 'Add it to your project with: npm install --save-dev github:
|
|
|
23
22
|
* @param {string} [projectPath=process.cwd()] - The project directory to resolve `gulp-imagemin` from.
|
|
24
23
|
* @returns {Function} The gulp-imagemin plugin factory.
|
|
25
24
|
* @throws {Error} With install instructions when gulp-imagemin is missing or is the ESM-only upstream release.
|
|
26
|
-
*/
|
|
27
|
-
const loadImagemin = (projectPath = process.cwd()) => {
|
|
28
|
-
const loaded = (0, _loadPeer.requirePeer)('gulp-imagemin', {
|
|
29
|
-
task: 'images',
|
|
30
|
-
installHint,
|
|
31
|
-
esmOnlyMessage: `gulp-imagemin could not be loaded because it is ESM-only. ${installHint}`,
|
|
32
|
-
projectPath
|
|
33
|
-
});
|
|
34
|
-
return loaded && (loaded.__esModule || loaded.default) ? loaded.default : loaded;
|
|
35
|
-
};
|
|
36
|
-
|
|
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
|
+
|
|
37
36
|
/**
|
|
38
37
|
* Move and optimize images into the browser directory.
|
|
39
38
|
* @memberOf module:partials
|
|
40
39
|
* @param {string|array} [imageSrc=src/images/pattern]
|
|
41
40
|
* @param {string} [imageDest=dest/image/folder]
|
|
42
41
|
* @return {stream.Stream}
|
|
43
|
-
*/
|
|
44
|
-
exports.loadImagemin = loadImagemin;
|
|
45
|
-
const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpConfig.get('images.to')) => {
|
|
46
|
-
const imagemin = loadImagemin();
|
|
47
|
-
// Gulp 5 reads files as utf8 text unless told otherwise, which corrupts binary images (and makes gulp-cache drop them).
|
|
48
|
-
return (0, _gulp.src)(imageSrc, {
|
|
49
|
-
encoding: false
|
|
50
|
-
}).pipe(
|
|
51
|
-
// Caching images that ran through imagemin
|
|
52
|
-
(0, _gulpCache.default)(imagemin({
|
|
53
|
-
interlaced: true,
|
|
54
|
-
silent: true,
|
|
55
|
-
verbose: false
|
|
56
|
-
}))).pipe((0, _gulp.dest)(imageDest));
|
|
57
|
-
};
|
|
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
|
+
};
|
|
58
57
|
exports.imagesFor = imagesFor;
|
|
@@ -136,11 +136,13 @@ const jsdocDocsFor = (srcPath = gulpConfig.get('docs.from'), outPath = gulpConfi
|
|
|
136
136
|
// quick-start example, which sets this explicitly, not assumed from jsdoc's own classic defaults.
|
|
137
137
|
recurse: true,
|
|
138
138
|
template: themeDir,
|
|
139
|
-
// clean-jsdoc-theme's own
|
|
140
|
-
// site root ("/"), while every page is in one
|
|
139
|
+
// clean-jsdoc-theme's own options for the name in its header and the home page's <title> (otherwise "Home").
|
|
140
|
+
// The header is given as a link: a plain-text title links to the site root ("/"), while every page is in one
|
|
141
|
+
// folder, so index.html is the home page wherever they are served. Both are printed unescaped by the theme.
|
|
141
142
|
...(title ? {
|
|
142
143
|
theme_opts: {
|
|
143
|
-
title: `<a href="index.html" class="sidebar-title sidebar-title-anchor">${escapeHtml(title)}</a
|
|
144
|
+
title: `<a href="index.html" class="sidebar-title sidebar-title-anchor">${escapeHtml(title)}</a>`,
|
|
145
|
+
homepageTitle: escapeHtml(title)
|
|
144
146
|
}
|
|
145
147
|
} : {}),
|
|
146
148
|
...(indexFile && _nodeFs.default.existsSync(indexFile) ? {
|
|
@@ -0,0 +1,41 @@
|
|
|
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.lintSource = void 0;
|
|
8
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
9
|
+
var _gulp = require("gulp");
|
|
10
|
+
var _neostandardLint = require("./neostandardLint.js");
|
|
11
|
+
var cache;
|
|
12
|
+
function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
|
|
13
|
+
/**
|
|
14
|
+
* Lint the project's source (srcPath: .js, .mjs and .cjs, plus .ts when typescript.enabled) with neostandard and
|
|
15
|
+
* write the automatic fixes back in place. Shared by the sourceLint (build) and lint (standalone) tasks.
|
|
16
|
+
* @memberOf module:partials
|
|
17
|
+
* @param {Object} [options={}]
|
|
18
|
+
* @param {boolean} [options.failOnError=false] - Fail once linting finishes if any errors could not be fixed.
|
|
19
|
+
* @returns {stream.Stream}
|
|
20
|
+
*/
|
|
21
|
+
const lintSource = ({
|
|
22
|
+
failOnError = false
|
|
23
|
+
} = {}) => {
|
|
24
|
+
const srcPath = gulpConfig.get('srcPath');
|
|
25
|
+
const ts = gulpConfig.get('typescript.enabled');
|
|
26
|
+
const patterns = [`${srcPath}/**/*.{js,mjs,cjs}`];
|
|
27
|
+
if (ts) {
|
|
28
|
+
patterns.push(`${srcPath}/**/*.ts`);
|
|
29
|
+
}
|
|
30
|
+
const linter = (0, _neostandardLint.neostandardLint)({
|
|
31
|
+
fix: true,
|
|
32
|
+
ts,
|
|
33
|
+
rules: gulpConfig.get('lint.rules'),
|
|
34
|
+
failOnError
|
|
35
|
+
});
|
|
36
|
+
const written = (0, _gulp.src)(patterns).pipe(linter).pipe((0, _gulp.dest)(srcPath));
|
|
37
|
+
// pipe() does not forward errors, and gulp only watches the returned stream, so pass the linter's failure along.
|
|
38
|
+
linter.on('error', error => written.emit('error', error));
|
|
39
|
+
return written;
|
|
40
|
+
};
|
|
41
|
+
exports.lintSource = lintSource;
|
|
@@ -1,34 +1,35 @@
|
|
|
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
|
-
|
|
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
|
+
// eslint-disable-next-line no-new-func -- deliberate, see above
|
|
17
|
+
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
18
|
+
|
|
18
19
|
/**
|
|
19
20
|
* Import an ES module (or any module) with a real dynamic import(), whichever build (ESM or CommonJS) this runs from.
|
|
20
21
|
* @memberOf module:partials
|
|
21
22
|
* @param {string} specifier - The package name, or the URL of a file.
|
|
22
23
|
* @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
|
-
|
|
24
|
+
*/
|
|
25
|
+
const importModule = specifier => dynamicImport(specifier);
|
|
26
|
+
exports.importModule = importModule;
|
|
27
|
+
const isMissing = (error, name) => error.code === 'MODULE_NOT_FOUND' && error.message.includes(`'${name}'`);
|
|
28
|
+
const notInstalled = (name, {
|
|
29
|
+
task,
|
|
30
|
+
installHint
|
|
31
|
+
}) => new Error(`The ${task} task needs the optional peer dependency ${name}, which is not installed. ${installHint}`);
|
|
32
|
+
|
|
32
33
|
/**
|
|
33
34
|
* Load an optional peer dependency (one which is only needed once a task runs, so projects which never use that task
|
|
34
35
|
* do not have to install it) with require(), from the project being built rather than from this package. When it is
|
|
@@ -42,29 +43,29 @@ const notInstalled = (name, {
|
|
|
42
43
|
* @param {string} [options.projectPath=process.cwd()] - The folder of the project (which has the package.json) being built.
|
|
43
44
|
* @returns {*} Whatever the package exports.
|
|
44
45
|
* @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
|
-
|
|
46
|
+
*/
|
|
47
|
+
const requirePeer = (name, {
|
|
48
|
+
task,
|
|
49
|
+
installHint,
|
|
50
|
+
esmOnlyMessage,
|
|
51
|
+
projectPath = process.cwd()
|
|
52
|
+
}) => {
|
|
53
|
+
try {
|
|
54
|
+
return (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json'))(name);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (isMissing(error, name)) {
|
|
57
|
+
throw notInstalled(name, {
|
|
58
|
+
task,
|
|
59
|
+
installHint
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (error.code === 'ERR_REQUIRE_ESM' && esmOnlyMessage) {
|
|
63
|
+
throw new Error(esmOnlyMessage);
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
68
69
|
/**
|
|
69
70
|
* Import an optional peer dependency which ships ESM-only, from the project being built. See {@link requirePeer}.
|
|
70
71
|
* @memberOf module:partials
|
|
@@ -75,25 +76,25 @@ const requirePeer = (name, {
|
|
|
75
76
|
* @param {string} [options.projectPath=process.cwd()] - The folder of the project (which has the package.json) being built.
|
|
76
77
|
* @returns {Promise<Object>} The module namespace.
|
|
77
78
|
* @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
|
-
};
|
|
79
|
+
*/
|
|
80
|
+
exports.requirePeer = requirePeer;
|
|
81
|
+
const importPeer = async (name, {
|
|
82
|
+
task,
|
|
83
|
+
installHint,
|
|
84
|
+
projectPath = process.cwd()
|
|
85
|
+
}) => {
|
|
86
|
+
let resolved;
|
|
87
|
+
try {
|
|
88
|
+
resolved = (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json')).resolve(name);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (isMissing(error, name)) {
|
|
91
|
+
throw notInstalled(name, {
|
|
92
|
+
task,
|
|
93
|
+
installHint
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
return importModule((0, _nodeUrl.pathToFileURL)(resolved).href);
|
|
99
|
+
};
|
|
99
100
|
exports.importPeer = importPeer;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.minifyFor = void 0;
|
|
7
|
-
var _gulp = require("gulp");
|
|
8
|
-
var _gulpUglifyEs = _interopRequireDefault(require("gulp-uglify-es"));
|
|
9
|
-
var _gulpRename = _interopRequireDefault(require("gulp-rename"));
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const uglify = _gulpUglifyEs.default
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.minifyFor = void 0;
|
|
7
|
+
var _gulp = require("gulp");
|
|
8
|
+
var _gulpUglifyEs = _interopRequireDefault(require("gulp-uglify-es"));
|
|
9
|
+
var _gulpRename = _interopRequireDefault(require("gulp-rename"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const uglify = Object.hasOwn(_gulpUglifyEs.default, 'default') ? _gulpUglifyEs.default.default : _gulpUglifyEs.default;
|
|
12
|
+
|
|
13
13
|
/**
|
|
14
14
|
* Minify files and rename the output with '.min' extension.
|
|
15
15
|
* @memberOf module:partials
|
|
16
16
|
* @returns {*}
|
|
17
|
-
*/
|
|
18
|
-
const minifyFor = (srcSearch, destination) => (0, _gulp.src)(srcSearch).pipe(uglify()).pipe((0, _gulpRename.default)({
|
|
19
|
-
extname: '.min.js'
|
|
20
|
-
})).pipe((0, _gulp.dest)(destination));
|
|
17
|
+
*/
|
|
18
|
+
const minifyFor = (srcSearch, destination) => (0, _gulp.src)(srcSearch).pipe(uglify()).pipe((0, _gulpRename.default)({
|
|
19
|
+
extname: '.min.js'
|
|
20
|
+
})).pipe((0, _gulp.dest)(destination));
|
|
21
21
|
exports.minifyFor = minifyFor;
|