@modern-js/app-tools 2.57.1-alpha.2 → 2.57.1-beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/dist/cjs/builder/builder-webpack/index.js +1 -1
  2. package/dist/cjs/builder/generator/index.js +2 -2
  3. package/dist/cjs/builder/index.js +2 -2
  4. package/dist/cjs/commands/build.js +0 -19
  5. package/dist/cjs/commands/dev.js +0 -9
  6. package/dist/cjs/commands/index.js +8 -8
  7. package/dist/cjs/index.js +1 -1
  8. package/dist/cjs/plugins/analyze/index.js +3 -3
  9. package/dist/cjs/plugins/deploy/dependencies/index.js +0 -1
  10. package/dist/cjs/plugins/deploy/dependencies/utils.js +2 -10
  11. package/dist/cjs/plugins/deploy/platforms/netlify.js +3 -10
  12. package/dist/cjs/plugins/deploy/platforms/{netlify-handler.js → netlifyEntry.js} +1 -27
  13. package/dist/cjs/plugins/deploy/platforms/node.js +2 -9
  14. package/dist/cjs/utils/loadPlugins.js +1 -1
  15. package/dist/cjs/utils/register.js +22 -38
  16. package/dist/esm/builder/generator/getBuilderEnvironments.js +2 -0
  17. package/dist/esm/builder/generator/index.js +1 -1
  18. package/dist/esm/builder/index.js +2 -2
  19. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +1 -1
  20. package/dist/esm/commands/build.js +16 -9
  21. package/dist/esm/commands/dev.js +55 -37
  22. package/dist/esm/commands/index.js +6 -6
  23. package/dist/esm/index.js +1 -42
  24. package/dist/esm/plugins/analyze/index.js +3 -4
  25. package/dist/esm/plugins/deploy/dependencies/index.js +3 -2
  26. package/dist/esm/plugins/deploy/dependencies/utils.js +4 -1
  27. package/dist/esm/utils/createServer.js +1 -1
  28. package/dist/esm-node/builder/generator/getBuilderEnvironments.js +1 -1
  29. package/dist/esm-node/builder/generator/index.js +1 -1
  30. package/dist/esm-node/builder/index.js +2 -2
  31. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +1 -1
  32. package/dist/esm-node/commands/build.js +3 -0
  33. package/dist/esm-node/commands/dev.js +24 -16
  34. package/dist/esm-node/commands/index.js +6 -6
  35. package/dist/esm-node/index.js +1 -17
  36. package/dist/esm-node/plugins/analyze/index.js +3 -4
  37. package/dist/esm-node/plugins/deploy/dependencies/index.js +2 -1
  38. package/dist/esm-node/plugins/deploy/dependencies/utils.js +4 -1
  39. package/dist/esm-node/utils/createServer.js +1 -1
  40. package/dist/types/builder/index.d.ts +1 -1
  41. package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +2 -0
  42. package/package.json +10 -10
  43. package/dist/cjs/esm/esbuild-loader.mjs +0 -20
  44. package/dist/cjs/esm/register-esm.mjs +0 -65
  45. package/dist/cjs/esm/ts-node-loader.mjs +0 -21
  46. package/dist/cjs/esm/utils.mjs +0 -28
  47. package/dist/cjs/plugins/deploy/platforms/netlify-entry-cjs.js +0 -3
  48. package/dist/cjs/plugins/deploy/platforms/netlify-entry-mjs.js +0 -28
  49. package/dist/esm/custom-loader.mjs +0 -41
  50. package/dist/esm/register-esm.mjs +0 -22
  51. package/dist/esm-node/esm/esbuild-loader.js +0 -39
  52. package/dist/esm-node/esm/register-esm.js +0 -39
  53. package/dist/esm-node/esm/ts-node-loader.js +0 -42
  54. package/dist/types/esm/esbuild-loader.d.mts +0 -6
  55. package/dist/types/esm/register-esm.d.mts +0 -5
  56. package/dist/types/esm/ts-node-loader.d.mts +0 -6
  57. package/dist/types/esm/utils.d.mts +0 -6
  58. package/dist/types/plugins/deploy/platforms/netlify-entry-cjs.d.ts +0 -1
  59. package/dist/types/plugins/deploy/platforms/netlify-entry-mjs.d.ts +0 -1
  60. package/dist/types/plugins/deploy/platforms/netlify-handler.d.ts +0 -1
@@ -0,0 +1,2 @@
1
+ declare function _default(request: any, context: any): Promise<any>;
2
+ export default _default;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.57.1-alpha.2",
18
+ "version": "2.57.1-beta.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -87,26 +87,26 @@
87
87
  "mlly": "^1.6.1",
88
88
  "pkg-types": "^1.1.0",
89
89
  "std-env": "^3.7.0",
90
+ "@modern-js/node-bundle-require": "2.57.0",
90
91
  "@modern-js/core": "2.57.0",
91
- "@modern-js/plugin": "2.57.0",
92
92
  "@modern-js/plugin-i18n": "2.57.0",
93
- "@modern-js/plugin-lint": "2.57.0",
94
- "@modern-js/node-bundle-require": "2.57.0",
95
93
  "@modern-js/prod-server": "2.57.0",
96
- "@modern-js/server-core": "2.57.0",
97
- "@modern-js/server-utils": "2.57.0",
98
- "@modern-js/rsbuild-plugin-esbuild": "2.57.0",
99
- "@modern-js/server": "2.57.0",
100
94
  "@modern-js/plugin-data-loader": "2.57.0",
95
+ "@modern-js/server-core": "2.57.1-alpha.0",
96
+ "@modern-js/plugin": "2.57.0",
101
97
  "@modern-js/types": "2.57.0",
98
+ "@modern-js/plugin-lint": "2.57.0",
99
+ "@modern-js/server-utils": "2.57.0",
100
+ "@modern-js/utils": "2.57.0",
101
+ "@modern-js/rsbuild-plugin-esbuild": "2.57.0",
102
102
  "@modern-js/uni-builder": "2.57.0",
103
- "@modern-js/utils": "2.57.0"
103
+ "@modern-js/server": "2.57.0"
104
104
  },
105
105
  "devDependencies": {
106
106
  "@rsbuild/plugin-swc": "1.0.1-beta.3",
107
107
  "@types/babel__traverse": "7.18.5",
108
108
  "@types/jest": "^29",
109
- "@types/node": "^16",
109
+ "@types/node": "^14",
110
110
  "jest": "^29",
111
111
  "ts-node": "^10.9.1",
112
112
  "tsconfig-paths": "^4.2.0",
@@ -1,20 +0,0 @@
1
- import { pathToFileURL } from 'url';
2
- import { createMatchPath } from './utils.mjs';
3
-
4
- let matchPath;
5
- export async function initialize({ appDir, alias, tsconfigPath }) {
6
- matchPath = createMatchPath({
7
- alias,
8
- appDir,
9
- tsconfigPath,
10
- });
11
- }
12
-
13
- export function resolve(specifier, context, defaultResolve) {
14
- const match = matchPath(specifier);
15
- return match
16
- ? defaultResolve(pathToFileURL(match).href, context)
17
- : defaultResolve(specifier, context);
18
- }
19
-
20
- export { load } from 'esbuild-register/loader';
@@ -1,65 +0,0 @@
1
- import path from 'node:path';
2
- import { fs, readTsConfigByFile } from '@modern-js/utils';
3
-
4
- const checkDep = async dep => {
5
- try {
6
- await import(dep);
7
- return true;
8
- } catch (error) {
9
- return false;
10
- }
11
- };
12
-
13
- export const registerEsm = async ({ appDir, distDir, alias }) => {
14
- const nodeVersion = process.versions.node;
15
- const versionArr = nodeVersion.split('.').map(Number);
16
- if (versionArr[0] < 18 || (versionArr[0] === 18 && versionArr[1] < 19)) {
17
- throw new Error(
18
- `The node version of the esm project must be greater than 18.19.0, current version is ${nodeVersion}`,
19
- );
20
- }
21
- const hasTsNode = await checkDep('ts-node');
22
- const TS_CONFIG_FILENAME = `tsconfig.json`;
23
- const tsconfigPath = path.resolve(appDir, TS_CONFIG_FILENAME);
24
- const hasTsconfig = await fs.pathExists(tsconfigPath);
25
- const { register } = await import('node:module');
26
- if (hasTsNode && hasTsconfig) {
27
- // These can be overridden by ts-node options in tsconfig.json
28
- process.env.TS_NODE_TRANSPILE_ONLY = true;
29
- process.env.TS_NODE_PROJECT = tsconfigPath;
30
- process.env.TS_NODE_SCOPE = true;
31
- process.env.TS_NODE_FILES = true;
32
- process.env.TS_NODE_IGNORE = `(?:^|/)node_modules/,(?:^|/)${path.relative(
33
- appDir,
34
- distDir,
35
- )}/`;
36
- register('./ts-node-loader.mjs', import.meta.url, {
37
- data: {
38
- appDir,
39
- distDir,
40
- alias,
41
- tsconfigPath,
42
- },
43
- });
44
- } else {
45
- process.env.MODERN_NODE_LOADER = 'esbuild';
46
- let tsConfig = {};
47
- if (hasTsconfig) {
48
- tsConfig = readTsConfigByFile(tsconfigPath);
49
- }
50
- const esbuildRegister = await import('esbuild-register/dist/node');
51
- esbuildRegister.register({
52
- tsconfigRaw: hasTsconfig ? tsConfig : undefined,
53
- hookIgnoreNodeModules: true,
54
- hookMatcher: fileName => !fileName.startsWith(distDir),
55
- });
56
- register('./esbuild-loader.mjs', import.meta.url, {
57
- data: {
58
- appDir,
59
- distDir,
60
- alias,
61
- tsconfigPath,
62
- },
63
- });
64
- }
65
- };
@@ -1,21 +0,0 @@
1
- import { pathToFileURL } from 'url';
2
- import { resolve as tsNodeResolve } from 'ts-node/esm';
3
- import { createMatchPath } from './utils.mjs';
4
-
5
- let matchPath;
6
- export async function initialize({ appDir, alias, tsconfigPath }) {
7
- matchPath = createMatchPath({
8
- alias,
9
- appDir,
10
- tsconfigPath,
11
- });
12
- }
13
-
14
- export function resolve(specifier, context, defaultResolve) {
15
- const match = matchPath(specifier, undefined, undefined, ['']);
16
- return match
17
- ? tsNodeResolve(pathToFileURL(match).href, context, defaultResolve)
18
- : tsNodeResolve(specifier, context, defaultResolve);
19
- }
20
-
21
- export { transformSource, load } from 'ts-node/esm';
@@ -1,28 +0,0 @@
1
- import path from 'path';
2
- import tsConfigPaths from '@modern-js/utils/tsconfig-paths';
3
- import { getAliasConfig } from '@modern-js/utils';
4
-
5
- export function createMatchPath({ alias, appDir, tsconfigPath }) {
6
- const aliasConfig = getAliasConfig(alias, {
7
- appDirectory: appDir,
8
- tsconfigPath,
9
- });
10
-
11
- const { paths = {}, absoluteBaseUrl = './' } = aliasConfig;
12
-
13
- const tsPaths = Object.keys(paths).reduce((o, key) => {
14
- let tsPath = paths[key];
15
- if (typeof tsPath === 'string' && path.isAbsolute(tsPath)) {
16
- tsPath = path.relative(absoluteBaseUrl, tsPath);
17
- }
18
- if (typeof tsPath === 'string') {
19
- tsPath = [tsPath];
20
- }
21
- return {
22
- ...o,
23
- [`${key}`]: tsPath,
24
- };
25
- }, {});
26
-
27
- return tsConfigPaths.createMatchPath(absoluteBaseUrl, tsPaths);
28
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- const { handler } = require("./netlify-handler");
3
- module.exports.default = handler;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var netlify_entry_mjs_exports = {};
20
- __export(netlify_entry_mjs_exports, {
21
- handler: () => import_netlify_handler.handler
22
- });
23
- module.exports = __toCommonJS(netlify_entry_mjs_exports);
24
- var import_netlify_handler = require("./netlify-handler");
25
- // Annotate the CommonJS export names for ESM import in node:
26
- 0 && (module.exports = {
27
- handler
28
- });
@@ -1,41 +0,0 @@
1
- import { pathToFileURL } from 'url';
2
- import { resolve as tsNodeResolve } from 'ts-node/esm';
3
- import * as tsConfigPaths from 'tsconfig-paths';
4
- import fs from 'fs/promises'
5
- import { getAliasConfig } from '@modern-js/utils';
6
- import path from 'path'
7
-
8
-
9
- let matchPath;
10
- export function initialize({ appDir, alias }){
11
- const TS_CONFIG_FILENAME = `tsconfig.json`;
12
- const aliasConfig = getAliasConfig(alias, {
13
- appDirectory: appDir,
14
- tsconfigPath: path.resolve(appDir, TS_CONFIG_FILENAME),
15
- });
16
- const { paths = {}, absoluteBaseUrl = './' } = aliasConfig;
17
- const tsPaths = Object.keys(paths).reduce((o, key) => {
18
- let tsPath = paths[key];
19
- if (typeof tsPath === 'string' && path.isAbsolute(tsPath)) {
20
- tsPath = path.relative(absoluteBaseUrl, tsPath);
21
- }
22
- if (typeof tsPath === 'string') {
23
- tsPath = [tsPath];
24
- }
25
- return {
26
- ...o,
27
- [`${key}`]: tsPath,
28
- };
29
- }, {});
30
-
31
- matchPath = tsConfigPaths.createMatchPath(absoluteBaseUrl, tsPaths);
32
- }
33
-
34
- export function resolve(specifier, context, defaultResolve) {
35
- const match = matchPath(specifier);
36
- return match
37
- ? tsNodeResolve(pathToFileURL(match).href, context, defaultResolve)
38
- : tsNodeResolve(specifier, context, defaultResolve);
39
- }
40
-
41
- export { transformSource, load } from 'ts-node/esm';
@@ -1,22 +0,0 @@
1
- import { register } from 'node:module';
2
- import path from 'node:path';
3
-
4
- export const registerEsm = async ({
5
- appDir,
6
- distDir,
7
- alias
8
- }) => {
9
- // These can be overridden by ts-node options in tsconfig.json
10
- process.env.TS_NODE_TRANSPILE_ONLY = true;
11
- process.env.TS_NODE_PROJECT = path.join(appDir, 'tsconfig.json');
12
- process.env.TS_NODE_SCOPE = true;
13
- process.env.TS_NODE_FILES = true;
14
- process.env.TS_NODE_IGNORE = `(?:^|/)node_modules/,(?:^|/)${path.relative(appDir, distDir)}/`
15
- register('./custom-loader.mjs', import.meta.url, {
16
- data: {
17
- appDir,
18
- distDir,
19
- alias
20
- }
21
- });
22
- };
@@ -1,39 +0,0 @@
1
- import { pathToFileURL } from "url";
2
- import * as tsConfigPaths from "@modern-js/utils/tsconfig-paths";
3
- import { getAliasConfig } from "@modern-js/utils";
4
- import path from "path";
5
- let matchPath;
6
- function initialize({ appDir, alias }) {
7
- const TS_CONFIG_FILENAME = `tsconfig.json`;
8
- const aliasConfig = getAliasConfig(alias, {
9
- appDirectory: appDir,
10
- tsconfigPath: path.resolve(appDir, TS_CONFIG_FILENAME)
11
- });
12
- const { paths = {}, absoluteBaseUrl = "./" } = aliasConfig;
13
- const tsPaths = Object.keys(paths).reduce((o, key) => {
14
- let tsPath = paths[key];
15
- if (typeof tsPath === "string" && path.isAbsolute(tsPath)) {
16
- tsPath = path.relative(absoluteBaseUrl, tsPath);
17
- }
18
- if (typeof tsPath === "string") {
19
- tsPath = [
20
- tsPath
21
- ];
22
- }
23
- return {
24
- ...o,
25
- [`${key}`]: tsPath
26
- };
27
- }, {});
28
- matchPath = tsConfigPaths.createMatchPath(absoluteBaseUrl, tsPaths);
29
- }
30
- function resolve(specifier, context, defaultResolve) {
31
- const match = matchPath(specifier);
32
- return match ? defaultResolve(pathToFileURL(match).href, context) : defaultResolve(specifier, context);
33
- }
34
- import { load } from "esbuild-register/loader";
35
- export {
36
- initialize,
37
- load,
38
- resolve
39
- };
@@ -1,39 +0,0 @@
1
- const import_meta = {};
2
- import { register } from "node:module";
3
- import path from "node:path";
4
- const checkDep = async (dep) => {
5
- try {
6
- await import(dep);
7
- return true;
8
- } catch (error) {
9
- return false;
10
- }
11
- };
12
- const registerEsm = async ({ appDir, distDir, alias }) => {
13
- const hasTsNode = await checkDep("ts-node");
14
- if (hasTsNode) {
15
- process.env.TS_NODE_TRANSPILE_ONLY = true;
16
- process.env.TS_NODE_PROJECT = path.join(appDir, "tsconfig.json");
17
- process.env.TS_NODE_SCOPE = true;
18
- process.env.TS_NODE_FILES = true;
19
- process.env.TS_NODE_IGNORE = `(?:^|/)node_modules/,(?:^|/)${path.relative(appDir, distDir)}/`;
20
- register("./ts-node-loader.mjs", import_meta.url, {
21
- data: {
22
- appDir,
23
- distDir,
24
- alias
25
- }
26
- });
27
- } else {
28
- register("./esbuild-loader.mjs", import_meta.url, {
29
- data: {
30
- appDir,
31
- distDir,
32
- alias
33
- }
34
- });
35
- }
36
- };
37
- export {
38
- registerEsm
39
- };
@@ -1,42 +0,0 @@
1
- import { pathToFileURL } from "url";
2
- import { resolve as tsNodeResolve } from "ts-node/esm";
3
- import * as tsConfigPaths from "@modern-js/utils/tsconfig-paths";
4
- import { getAliasConfig } from "@modern-js/utils";
5
- import path from "path";
6
- console.log("ttttttttttttt", tsConfigPaths);
7
- let matchPath;
8
- function initialize({ appDir, alias }) {
9
- const TS_CONFIG_FILENAME = `tsconfig.json`;
10
- const aliasConfig = getAliasConfig(alias, {
11
- appDirectory: appDir,
12
- tsconfigPath: path.resolve(appDir, TS_CONFIG_FILENAME)
13
- });
14
- const { paths = {}, absoluteBaseUrl = "./" } = aliasConfig;
15
- const tsPaths = Object.keys(paths).reduce((o, key) => {
16
- let tsPath = paths[key];
17
- if (typeof tsPath === "string" && path.isAbsolute(tsPath)) {
18
- tsPath = path.relative(absoluteBaseUrl, tsPath);
19
- }
20
- if (typeof tsPath === "string") {
21
- tsPath = [
22
- tsPath
23
- ];
24
- }
25
- return {
26
- ...o,
27
- [`${key}`]: tsPath
28
- };
29
- }, {});
30
- matchPath = tsConfigPaths.createMatchPath(absoluteBaseUrl, tsPaths);
31
- }
32
- function resolve(specifier, context, defaultResolve) {
33
- const match = matchPath(specifier);
34
- return match ? tsNodeResolve(pathToFileURL(match).href, context, defaultResolve) : tsNodeResolve(specifier, context, defaultResolve);
35
- }
36
- import { transformSource, load } from "ts-node/esm";
37
- export {
38
- initialize,
39
- load,
40
- resolve,
41
- transformSource
42
- };
@@ -1,6 +0,0 @@
1
- export function initialize({ appDir, alias, tsconfigPath }: {
2
- appDir: any;
3
- alias: any;
4
- tsconfigPath: any;
5
- }): Promise<void>;
6
- export function resolve(specifier: any, context: any, defaultResolve: any): any;
@@ -1,5 +0,0 @@
1
- export function registerEsm({ appDir, distDir, alias }: {
2
- appDir: any;
3
- distDir: any;
4
- alias: any;
5
- }): Promise<void>;
@@ -1,6 +0,0 @@
1
- export function initialize({ appDir, alias, tsconfigPath }: {
2
- appDir: any;
3
- alias: any;
4
- tsconfigPath: any;
5
- }): Promise<void>;
6
- export function resolve(specifier: any, context: any, defaultResolve: any): any;
@@ -1,6 +0,0 @@
1
- export function createMatchPath({ alias, appDir, tsconfigPath }: {
2
- alias: any;
3
- appDir: any;
4
- tsconfigPath: any;
5
- }): tsConfigPaths.MatchPath;
6
- import tsConfigPaths from '@modern-js/utils/tsconfig-paths';
@@ -1 +0,0 @@
1
- export default handler;
@@ -1 +0,0 @@
1
- export function createHandler(): Promise<any>;