@modern-js/node-bundle-require 1.3.3 → 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 +21 -0
- package/dist/js/modern/bundle.js +3 -5
- package/dist/js/modern/index.js +6 -3
- package/dist/js/node/bundle.js +5 -4
- 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 +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @modern-js/node-bundle-require
|
|
2
2
|
|
|
3
|
+
## 1.3.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8d0eb81f5: change load config logic
|
|
8
|
+
|
|
9
|
+
## 1.3.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a1198d509: feat: bump babel 7.18.0
|
|
14
|
+
|
|
15
|
+
## 1.3.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- b8cfc42cd: feat: prebundle tsconfig-paths and nanoid
|
|
20
|
+
- Updated dependencies [b8cfc42cd]
|
|
21
|
+
- Updated dependencies [804a5bb8a]
|
|
22
|
+
- @modern-js/utils@1.7.4
|
|
23
|
+
|
|
3
24
|
## 1.3.3
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/js/modern/bundle.js
CHANGED
|
@@ -5,8 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
7
|
import path from 'path';
|
|
8
|
-
import { fs, CONFIG_CACHE_DIR, createDebugger } from '@modern-js/utils';
|
|
9
|
-
import { nanoid } from 'nanoid';
|
|
8
|
+
import { fs, nanoid, CONFIG_CACHE_DIR, createDebugger } from '@modern-js/utils';
|
|
10
9
|
import { build } from 'esbuild';
|
|
11
10
|
const debug = createDebugger('node-bundle');
|
|
12
11
|
const JS_EXT_RE = /\.(mjs|cjs|ts|js|tsx|jsx)$/; // Must not start with "/" or "./" or "../"
|
|
@@ -23,8 +22,7 @@ function inferLoader(ext) {
|
|
|
23
22
|
return ext.slice(1);
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
const defaultGetOutputFile = filepath => path.resolve(CONFIG_CACHE_DIR, `${filepath}-${Date.now()}.${nanoid()}.bundled.cjs`);
|
|
27
|
-
|
|
25
|
+
export const defaultGetOutputFile = async filepath => path.resolve(CONFIG_CACHE_DIR, `${filepath}-${Date.now()}.${nanoid()}.bundled.cjs`);
|
|
28
26
|
export async function bundle(filepath, options) {
|
|
29
27
|
if (!JS_EXT_RE.test(filepath)) {
|
|
30
28
|
throw new Error(`${filepath} is not a valid JS file`);
|
|
@@ -32,7 +30,7 @@ export async function bundle(filepath, options) {
|
|
|
32
30
|
|
|
33
31
|
debug('bundle', filepath, options);
|
|
34
32
|
const getOutputFile = (options === null || options === void 0 ? void 0 : options.getOutputFile) || defaultGetOutputFile;
|
|
35
|
-
const outfile = getOutputFile(path.basename(filepath));
|
|
33
|
+
const outfile = await getOutputFile(path.basename(filepath));
|
|
36
34
|
await build(_objectSpread(_objectSpread({
|
|
37
35
|
entryPoints: [filepath],
|
|
38
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,13 +5,12 @@ 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
|
|
|
11
12
|
var _utils = require("@modern-js/utils");
|
|
12
13
|
|
|
13
|
-
var _nanoid = require("nanoid");
|
|
14
|
-
|
|
15
14
|
var _esbuild = require("esbuild");
|
|
16
15
|
|
|
17
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -38,7 +37,9 @@ function inferLoader(ext) {
|
|
|
38
37
|
return ext.slice(1);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
const defaultGetOutputFile = filepath => _path.default.resolve(_utils.CONFIG_CACHE_DIR, `${filepath}-${Date.now()}.${(0,
|
|
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;
|
|
42
43
|
|
|
43
44
|
async function bundle(filepath, options) {
|
|
44
45
|
if (!JS_EXT_RE.test(filepath)) {
|
|
@@ -47,7 +48,7 @@ async function bundle(filepath, options) {
|
|
|
47
48
|
|
|
48
49
|
debug('bundle', filepath, options);
|
|
49
50
|
const getOutputFile = (options === null || options === void 0 ? void 0 : options.getOutputFile) || defaultGetOutputFile;
|
|
50
|
-
const outfile = getOutputFile(_path.default.basename(filepath));
|
|
51
|
+
const outfile = await getOutputFile(_path.default.basename(filepath));
|
|
51
52
|
await (0, _esbuild.build)(_objectSpread(_objectSpread({
|
|
52
53
|
entryPoints: [filepath],
|
|
53
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",
|
|
@@ -39,12 +39,11 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@babel/runtime": "^7",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
42
|
+
"@babel/runtime": "^7.18.0",
|
|
43
|
+
"@modern-js/utils": "^1.7.4",
|
|
44
|
+
"esbuild": "^0.14.38"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@modern-js/utils": "1.7.3",
|
|
48
47
|
"@scripts/build": "0.0.0",
|
|
49
48
|
"@scripts/jest-config": "0.0.0",
|
|
50
49
|
"@types/jest": "^27",
|
|
@@ -74,7 +73,8 @@
|
|
|
74
73
|
"files": [
|
|
75
74
|
"src/**/*",
|
|
76
75
|
"tsconfig.json",
|
|
77
|
-
"package.json"
|
|
76
|
+
"package.json",
|
|
77
|
+
"tests/**/*"
|
|
78
78
|
],
|
|
79
79
|
"output": []
|
|
80
80
|
}
|