@modern-js/utils 1.3.7-alpha.prebundle.0 → 1.4.1

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/constants.d.ts +13 -0
  3. package/dist/constants.js +14 -1
  4. package/dist/getServerConfig.d.ts +1 -0
  5. package/dist/{src/watch.js → getServerConfig.js} +8 -34
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +2 -0
  8. package/dist/ssrHelpers.d.ts +4 -0
  9. package/dist/ssrHelpers.js +7 -0
  10. package/dist/storage.d.ts +5 -0
  11. package/dist/storage.js +61 -0
  12. package/package.json +2 -2
  13. package/dist/compiled/upath/index.d.ts +0 -225
  14. package/dist/compiled/upath/index.js +0 -1
  15. package/dist/pkgUp.d.ts +0 -2
  16. package/dist/pkgUp.js +0 -8
  17. package/dist/src/FileSizeReporter.d.ts +0 -16
  18. package/dist/src/FileSizeReporter.js +0 -152
  19. package/dist/src/alias.d.ts +0 -21
  20. package/dist/src/alias.js +0 -62
  21. package/dist/src/applyOptionsChain.d.ts +0 -6
  22. package/dist/src/applyOptionsChain.js +0 -30
  23. package/dist/src/clearConsole.d.ts +0 -1
  24. package/dist/src/clearConsole.js +0 -9
  25. package/dist/src/compatRequire.d.ts +0 -8
  26. package/dist/src/compatRequire.js +0 -28
  27. package/dist/src/compiled.d.ts +0 -7
  28. package/dist/src/compiled.js +0 -19
  29. package/dist/src/constants.d.ts +0 -209
  30. package/dist/src/constants.js +0 -264
  31. package/dist/src/debug.d.ts +0 -7
  32. package/dist/src/debug.js +0 -14
  33. package/dist/src/emptyDir.d.ts +0 -1
  34. package/dist/src/emptyDir.js +0 -22
  35. package/dist/src/ensureAbsolutePath.d.ts +0 -7
  36. package/dist/src/ensureAbsolutePath.js +0 -15
  37. package/dist/src/findExists.d.ts +0 -6
  38. package/dist/src/findExists.js +0 -21
  39. package/dist/src/format.d.ts +0 -16
  40. package/dist/src/format.js +0 -115
  41. package/dist/src/generateMetaTags.d.ts +0 -16
  42. package/dist/src/generateMetaTags.js +0 -48
  43. package/dist/src/getBrowserslist.d.ts +0 -2
  44. package/dist/src/getBrowserslist.js +0 -7
  45. package/dist/src/getCacheIdentifier.d.ts +0 -7
  46. package/dist/src/getCacheIdentifier.js +0 -24
  47. package/dist/src/getEntryOptions.d.ts +0 -1
  48. package/dist/src/getEntryOptions.js +0 -26
  49. package/dist/src/getPackageManager.d.ts +0 -1
  50. package/dist/src/getPackageManager.js +0 -47
  51. package/dist/src/getPort.d.ts +0 -7
  52. package/dist/src/getPort.js +0 -62
  53. package/dist/src/import.d.ts +0 -5
  54. package/dist/src/import.js +0 -10
  55. package/dist/src/index.d.ts +0 -32
  56. package/dist/src/index.js +0 -57
  57. package/dist/src/is/index.d.ts +0 -34
  58. package/dist/src/is/index.js +0 -82
  59. package/dist/src/is/node-env.d.ts +0 -4
  60. package/dist/src/is/node-env.js +0 -12
  61. package/dist/src/is/platform.d.ts +0 -2
  62. package/dist/src/is/platform.js +0 -10
  63. package/dist/src/is/type.d.ts +0 -8
  64. package/dist/src/is/type.js +0 -38
  65. package/dist/src/logger.d.ts +0 -63
  66. package/dist/src/logger.js +0 -129
  67. package/dist/src/monorepo.d.ts +0 -11
  68. package/dist/src/monorepo.js +0 -81
  69. package/dist/src/nodeEnv.d.ts +0 -3
  70. package/dist/src/nodeEnv.js +0 -52
  71. package/dist/src/path.d.ts +0 -3
  72. package/dist/src/path.js +0 -14
  73. package/dist/src/prettyInstructions.d.ts +0 -6
  74. package/dist/src/prettyInstructions.js +0 -64
  75. package/dist/src/printBuildError.d.ts +0 -8
  76. package/dist/src/printBuildError.js +0 -43
  77. package/dist/src/readTsConfig.d.ts +0 -2
  78. package/dist/src/readTsConfig.js +0 -19
  79. package/dist/src/removeSlash.d.ts +0 -3
  80. package/dist/src/removeSlash.js +0 -9
  81. package/dist/src/runtimeExports.d.ts +0 -4
  82. package/dist/src/runtimeExports.js +0 -53
  83. package/dist/src/wait.d.ts +0 -2
  84. package/dist/src/wait.js +0 -7
  85. package/dist/src/watch.d.ts +0 -8
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.readTsConfigByFile = exports.readTsConfig = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const readTsConfig = (root) => {
9
- // import typescript from 'typescript' cause eslint fromat error.
10
- const typescript = require('typescript');
11
- return typescript.readConfigFile(path_1.default.resolve(root, './tsconfig.json'), typescript.sys.readFile).config;
12
- };
13
- exports.readTsConfig = readTsConfig;
14
- const readTsConfigByFile = (filename) => {
15
- // import typescript from 'typescript' cause eslint fromat error.
16
- const typescript = require('typescript');
17
- return typescript.readConfigFile(path_1.default.resolve(filename), typescript.sys.readFile).config;
18
- };
19
- exports.readTsConfigByFile = readTsConfigByFile;
@@ -1,3 +0,0 @@
1
- export declare const removeLeadingSlash: (s: string) => string;
2
- export declare const removeTailSlash: (s: string) => string;
3
- export declare const removeSlash: (s: string) => string;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeSlash = exports.removeTailSlash = exports.removeLeadingSlash = void 0;
4
- const removeLeadingSlash = (s) => s.replace(/^\/+/, '');
5
- exports.removeLeadingSlash = removeLeadingSlash;
6
- const removeTailSlash = (s) => s.replace(/\/+$/, '');
7
- exports.removeTailSlash = removeTailSlash;
8
- const removeSlash = (s) => (0, exports.removeLeadingSlash)((0, exports.removeTailSlash)(s));
9
- exports.removeSlash = removeSlash;
@@ -1,4 +0,0 @@
1
- export declare const createRuntimeExportsUtils: (pwd: any, namespace: string, ts?: any) => {
2
- addExport: (statement: string) => void;
3
- getPath: () => string;
4
- };
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createRuntimeExportsUtils = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const path_2 = require("./path");
10
- const memo = (fn) => {
11
- const cache = new Map();
12
- return (...params) => {
13
- const stringifiedParams = JSON.stringify(params);
14
- const cachedResult = cache.get(stringifiedParams);
15
- if (cachedResult) {
16
- return cachedResult;
17
- }
18
- const res = fn(...params);
19
- cache.set(stringifiedParams, res);
20
- return res;
21
- };
22
- };
23
- exports.createRuntimeExportsUtils = memo((pwd = '', namespace, ts = false) => {
24
- const entryExportFile = path_1.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.js` : 'index.js'}`);
25
- const entryExportTsFile = path_1.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.d.ts` : 'index.d.ts'}`);
26
- // const ensure = () => {
27
- // if (!fs.existsSync(entryExportFile)) {
28
- // fs.outputFileSync(entryExportFile, '');
29
- // }
30
- // fs.ensureFileSync(entryExportFile);
31
- // };
32
- const addExport = (statement) => {
33
- // eslint-disable-next-line no-param-reassign
34
- statement = (0, path_2.normalizeOutputPath)(statement);
35
- try {
36
- fs_extra_1.default.ensureFileSync(entryExportFile);
37
- fs_extra_1.default.ensureFileSync(entryExportTsFile);
38
- if (!fs_extra_1.default.readFileSync(entryExportFile, 'utf8').includes(statement)) {
39
- fs_extra_1.default.appendFileSync(entryExportFile, `${statement}\n`);
40
- ts &&
41
- fs_extra_1.default.appendFileSync(entryExportTsFile, `${statement.replace('.js', '.d')}\n`);
42
- }
43
- }
44
- catch (_a) {
45
- // FIXME:
46
- }
47
- };
48
- const getPath = () => entryExportFile;
49
- return {
50
- addExport,
51
- getPath,
52
- };
53
- });
@@ -1,2 +0,0 @@
1
- declare const wait: (time?: number) => Promise<unknown>;
2
- export { wait };
package/dist/src/wait.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wait = void 0;
4
- const wait = (time = 0) => new Promise(resolve => {
5
- setTimeout(resolve, time);
6
- });
7
- exports.wait = wait;
@@ -1,8 +0,0 @@
1
- export declare type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
2
- export declare const WatchChangeType: Record<'ADD' | 'UNLINK' | 'CHANGE', WatchChangeTypeValueT>;
3
- declare type RunTaskType = (option: {
4
- changedFilePath: string;
5
- changeType: WatchChangeTypeValueT;
6
- }) => void | Promise<void>;
7
- export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("chokidar").FSWatcher;
8
- export {};