@modern-js/node-bundle-require 1.3.5 → 1.3.6
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/CHANGELOG.md +6 -0
- package/dist/js/modern/bundle.js +2 -3
- package/dist/js/modern/index.js +6 -3
- package/dist/js/node/bundle.js +5 -2
- package/dist/js/node/index.js +10 -1
- package/dist/types/bundle.d.ts +7 -1
- package/dist/types/index.d.ts +4 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/js/modern/bundle.js
CHANGED
|
@@ -22,8 +22,7 @@ function inferLoader(ext) {
|
|
|
22
22
|
return ext.slice(1);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const defaultGetOutputFile = filepath => path.resolve(CONFIG_CACHE_DIR, `${filepath}-${Date.now()}.${nanoid()}.bundled.cjs`);
|
|
26
|
-
|
|
25
|
+
export const defaultGetOutputFile = async filepath => path.resolve(CONFIG_CACHE_DIR, `${filepath}-${Date.now()}.${nanoid()}.bundled.cjs`);
|
|
27
26
|
export async function bundle(filepath, options) {
|
|
28
27
|
if (!JS_EXT_RE.test(filepath)) {
|
|
29
28
|
throw new Error(`${filepath} is not a valid JS file`);
|
|
@@ -31,7 +30,7 @@ export async function bundle(filepath, options) {
|
|
|
31
30
|
|
|
32
31
|
debug('bundle', filepath, options);
|
|
33
32
|
const getOutputFile = (options === null || options === void 0 ? void 0 : options.getOutputFile) || defaultGetOutputFile;
|
|
34
|
-
const outfile = getOutputFile(path.basename(filepath));
|
|
33
|
+
const outfile = await getOutputFile(path.basename(filepath));
|
|
35
34
|
await build(_objectSpread(_objectSpread({
|
|
36
35
|
entryPoints: [filepath],
|
|
37
36
|
outfile,
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fs } from '@modern-js/utils';
|
|
2
|
-
import { bundle } from "./bundle";
|
|
3
|
-
export { bundle };
|
|
2
|
+
import { bundle, defaultGetOutputFile } from "./bundle";
|
|
3
|
+
export { bundle, defaultGetOutputFile };
|
|
4
4
|
|
|
5
5
|
function deleteRequireCache(path) {
|
|
6
6
|
if (require.cache[path]) {
|
|
@@ -24,7 +24,10 @@ export async function bundleRequire(filepath, options) {
|
|
|
24
24
|
|
|
25
25
|
deleteRequireCache(configFile);
|
|
26
26
|
} finally {
|
|
27
|
-
|
|
27
|
+
// default auto clear configFile
|
|
28
|
+
if ((options === null || options === void 0 ? void 0 : options.autoClear) === undefined || options.autoClear) {
|
|
29
|
+
fs.unlinkSync(configFile);
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
return mod;
|
package/dist/js/node/bundle.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.EXTERNAL_REGEXP = void 0;
|
|
7
7
|
exports.bundle = bundle;
|
|
8
|
+
exports.defaultGetOutputFile = void 0;
|
|
8
9
|
|
|
9
10
|
var _path = _interopRequireDefault(require("path"));
|
|
10
11
|
|
|
@@ -36,7 +37,9 @@ function inferLoader(ext) {
|
|
|
36
37
|
return ext.slice(1);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
const defaultGetOutputFile = filepath => _path.default.resolve(_utils.CONFIG_CACHE_DIR, `${filepath}-${Date.now()}.${(0, _utils.nanoid)()}.bundled.cjs`);
|
|
40
|
+
const defaultGetOutputFile = async filepath => _path.default.resolve(_utils.CONFIG_CACHE_DIR, `${filepath}-${Date.now()}.${(0, _utils.nanoid)()}.bundled.cjs`);
|
|
41
|
+
|
|
42
|
+
exports.defaultGetOutputFile = defaultGetOutputFile;
|
|
40
43
|
|
|
41
44
|
async function bundle(filepath, options) {
|
|
42
45
|
if (!JS_EXT_RE.test(filepath)) {
|
|
@@ -45,7 +48,7 @@ async function bundle(filepath, options) {
|
|
|
45
48
|
|
|
46
49
|
debug('bundle', filepath, options);
|
|
47
50
|
const getOutputFile = (options === null || options === void 0 ? void 0 : options.getOutputFile) || defaultGetOutputFile;
|
|
48
|
-
const outfile = getOutputFile(_path.default.basename(filepath));
|
|
51
|
+
const outfile = await getOutputFile(_path.default.basename(filepath));
|
|
49
52
|
await (0, _esbuild.build)(_objectSpread(_objectSpread({
|
|
50
53
|
entryPoints: [filepath],
|
|
51
54
|
outfile,
|
package/dist/js/node/index.js
CHANGED
|
@@ -10,6 +10,12 @@ Object.defineProperty(exports, "bundle", {
|
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
exports.bundleRequire = bundleRequire;
|
|
13
|
+
Object.defineProperty(exports, "defaultGetOutputFile", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _bundle.defaultGetOutputFile;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
13
19
|
|
|
14
20
|
var _utils = require("@modern-js/utils");
|
|
15
21
|
|
|
@@ -37,7 +43,10 @@ async function bundleRequire(filepath, options) {
|
|
|
37
43
|
|
|
38
44
|
deleteRequireCache(configFile);
|
|
39
45
|
} finally {
|
|
40
|
-
|
|
46
|
+
// default auto clear configFile
|
|
47
|
+
if ((options === null || options === void 0 ? void 0 : options.autoClear) === undefined || options.autoClear) {
|
|
48
|
+
_utils.fs.unlinkSync(configFile);
|
|
49
|
+
}
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
return mod;
|
package/dist/types/bundle.d.ts
CHANGED
|
@@ -22,6 +22,12 @@ export interface Options {
|
|
|
22
22
|
* By default we simply replace the extension with `.bundled.cjs`
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
getOutputFile?: (filepath: string) => string
|
|
25
|
+
getOutputFile?: (filepath: string) => Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* auto clear bundle file
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
autoClear?: boolean;
|
|
26
31
|
}
|
|
32
|
+
export declare const defaultGetOutputFile: (filepath: string) => Promise<string>;
|
|
27
33
|
export declare function bundle(filepath: string, options?: Options): Promise<string>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { Options } from './bundle';
|
|
2
|
+
import { bundle, defaultGetOutputFile } from './bundle';
|
|
3
|
+
export { bundle, defaultGetOutputFile };
|
|
4
|
+
export type { Options };
|
|
3
5
|
export declare function bundleRequire(filepath: string, options?: Options): Promise<any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/node-bundle-require",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "The meta-framework suite designed from scratch for frontend-focused modern web development.",
|
|
5
5
|
"homepage": "https://modernjs.dev",
|
|
6
6
|
"bugs": "https://github.com/modern-js-dev/modern.js/issues",
|