@modern-js/app-tools 3.8.2 → 3.9.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.
@@ -46,6 +46,7 @@ const registerModuleHooks = async ({ appDir, distDir, baseUrl, paths })=>{
46
46
  process.env.TS_NODE_IGNORE = `(?:^|/)node_modules/,(?:^|/)${external_node_path_namespaceObject.relative(appDir, distDir)}/`;
47
47
  register('./ts-node-loader.mjs', __rslib_import_meta_url__, {
48
48
  data: {
49
+ appDir,
49
50
  baseUrl,
50
51
  paths
51
52
  }
@@ -10,6 +10,7 @@ export const registerModuleHooks = async ({ appDir, distDir, baseUrl, paths })=>
10
10
  process.env.TS_NODE_IGNORE = `(?:^|/)node_modules/,(?:^|/)${path.relative(appDir, distDir)}/`;
11
11
  register('./ts-node-loader.mjs', import.meta.url, {
12
12
  data: {
13
+ appDir,
13
14
  baseUrl,
14
15
  paths
15
16
  }
@@ -32,17 +32,13 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  load: ()=>load,
33
33
  resolve: ()=>resolve
34
34
  });
35
- const external_url_namespaceObject = require("url");
36
- const utils_namespaceObject = require("@modern-js/utils");
37
- const tsconfig_paths_namespaceObject = require("@modern-js/utils/tsconfig-paths");
38
35
  const esm_namespaceObject = require("ts-node/esm");
39
- let matchPath;
40
- async function initialize({ baseUrl, paths }) {
41
- matchPath = (0, tsconfig_paths_namespaceObject.createMatchPath)(baseUrl || './', paths || {});
36
+ const external_ts_paths_loader_js_namespaceObject = require("./ts-paths-loader.js");
37
+ async function initialize(config) {
38
+ await (0, external_ts_paths_loader_js_namespaceObject.initialize)(config);
42
39
  }
43
40
  function resolve(specifier, context, defaultResolve) {
44
- const match = (0, utils_namespaceObject.findMatchedSourcePath)(matchPath, specifier);
45
- return match ? (0, esm_namespaceObject.resolve)((0, external_url_namespaceObject.pathToFileURL)((0, utils_namespaceObject.findSourceEntry)(match) || match).href, context, defaultResolve) : (0, esm_namespaceObject.resolve)(specifier, context, defaultResolve);
41
+ return (0, external_ts_paths_loader_js_namespaceObject.resolve)(specifier, context, (specifier, context)=>(0, esm_namespaceObject.resolve)(specifier, context, defaultResolve));
46
42
  }
47
43
  function load(url, context, defaultLoad) {
48
44
  const filePath = new URL(url).pathname;
@@ -1,15 +1,11 @@
1
- import { pathToFileURL } from 'url';
2
- import { findMatchedSourcePath, findSourceEntry } from '@modern-js/utils';
3
- import { createMatchPath } from '@modern-js/utils/tsconfig-paths';
4
1
  import { resolve as tsNodeResolve } from 'ts-node/esm';
5
2
  import { load as tsNodeLoad } from 'ts-node/esm';
6
- let matchPath;
7
- export async function initialize({ baseUrl, paths }) {
8
- matchPath = createMatchPath(baseUrl || './', paths || {});
3
+ import { initialize as initializeTsPathsLoader, resolve as resolveTsPaths } from './ts-paths-loader.mjs';
4
+ export async function initialize(config) {
5
+ await initializeTsPathsLoader(config);
9
6
  }
10
7
  export function resolve(specifier, context, defaultResolve) {
11
- const match = findMatchedSourcePath(matchPath, specifier);
12
- return match ? tsNodeResolve(pathToFileURL(findSourceEntry(match) || match).href, context, defaultResolve) : tsNodeResolve(specifier, context, defaultResolve);
8
+ return resolveTsPaths(specifier, context, (specifier, context)=>tsNodeResolve(specifier, context, defaultResolve));
13
9
  }
14
10
  export function load(url, context, defaultLoad) {
15
11
  const filePath = new URL(url).pathname;
@@ -10,6 +10,7 @@ const registerModuleHooks = async ({ appDir, distDir, baseUrl, paths })=>{
10
10
  process.env.TS_NODE_IGNORE = `(?:^|/)node_modules/,(?:^|/)${node_path.relative(appDir, distDir)}/`;
11
11
  register('./ts-node-loader.mjs', import.meta.url, {
12
12
  data: {
13
+ appDir,
13
14
  baseUrl,
14
15
  paths
15
16
  }
@@ -1,14 +1,10 @@
1
- import { pathToFileURL } from "url";
2
- import { findMatchedSourcePath, findSourceEntry } from "@modern-js/utils";
3
- import { createMatchPath } from "@modern-js/utils/tsconfig-paths";
4
1
  import { load, resolve } from "ts-node/esm";
5
- let matchPath;
6
- async function initialize({ baseUrl, paths }) {
7
- matchPath = createMatchPath(baseUrl || './', paths || {});
2
+ import { initialize, resolve as external_ts_paths_loader_mjs_resolve } from "./ts-paths-loader.mjs";
3
+ async function ts_node_loader_initialize(config) {
4
+ await initialize(config);
8
5
  }
9
6
  function ts_node_loader_resolve(specifier, context, defaultResolve) {
10
- const match = findMatchedSourcePath(matchPath, specifier);
11
- return match ? resolve(pathToFileURL(findSourceEntry(match) || match).href, context, defaultResolve) : resolve(specifier, context, defaultResolve);
7
+ return external_ts_paths_loader_mjs_resolve(specifier, context, (specifier, context)=>resolve(specifier, context, defaultResolve));
12
8
  }
13
9
  function ts_node_loader_load(url, context, defaultLoad) {
14
10
  const filePath = new URL(url).pathname;
@@ -16,4 +12,4 @@ function ts_node_loader_load(url, context, defaultLoad) {
16
12
  if (filePath.includes('node_modules')) return defaultLoad(url, context);
17
13
  return load(url, context, defaultLoad);
18
14
  }
19
- export { initialize, ts_node_loader_load as load, ts_node_loader_resolve as resolve };
15
+ export { ts_node_loader_initialize as initialize, ts_node_loader_load as load, ts_node_loader_resolve as resolve };
@@ -1,7 +1,7 @@
1
1
  import path from "path";
2
2
  import { findExists, fs } from "@modern-js/utils";
3
3
  import { HTML_PARTIALS_EXTENSIONS, HTML_PARTIALS_FOLDER } from "./constants.mjs";
4
- import * as __rspack_external__templates_mjs_4da4c6c8 from "./templates.mjs";
4
+ import * as __rspack_external__templates_mjs_ab577925 from "./templates.mjs";
5
5
  const findPartials = (dir, entryName, position)=>{
6
6
  if (fs.existsSync(dir)) {
7
7
  const base = findExists(HTML_PARTIALS_EXTENSIONS.map((ext)=>path.resolve(dir, `${position}${ext}`)));
@@ -70,7 +70,7 @@ const getHtmlTemplate = async (entrypoints, hooks, { appContext, config })=>{
70
70
  partials: getModifyHtmlPartials(partials)
71
71
  });
72
72
  const templatePath = path.resolve(internalDirectory, entryName, 'index.html');
73
- fs.outputFileSync(templatePath, __rspack_external__templates_mjs_4da4c6c8.html(partials), 'utf8');
73
+ fs.outputFileSync(templatePath, __rspack_external__templates_mjs_ab577925.html(partials), 'utf8');
74
74
  htmlTemplates[entryName] = templatePath.replace(/\\/g, '/');
75
75
  partialsByEntrypoint[entryName] = partials;
76
76
  const bottomTemplate = findPartials(htmlDir, name, "bottom");
@@ -1,8 +1,8 @@
1
1
  import fs from "fs";
2
2
  import { parse } from "@babel/parser";
3
3
  import traverse from "@babel/traverse";
4
- import * as __rspack_external__babel_types_69e65b52 from "@babel/types";
5
- const isFunction = (node)=>__rspack_external__babel_types_69e65b52.isFunctionDeclaration(node) || __rspack_external__babel_types_69e65b52.isFunctionExpression(node) || __rspack_external__babel_types_69e65b52.isArrowFunctionExpression(node);
4
+ import * as __rspack_external__babel_types_6e8337dd from "@babel/types";
5
+ const isFunction = (node)=>__rspack_external__babel_types_6e8337dd.isFunctionDeclaration(node) || __rspack_external__babel_types_6e8337dd.isFunctionExpression(node) || __rspack_external__babel_types_6e8337dd.isArrowFunctionExpression(node);
6
6
  const isDefaultExportFunction = (file)=>{
7
7
  if (!file || !fs.existsSync(file)) return false;
8
8
  const ast = parse(fs.readFileSync(file, 'utf8'), {
@@ -11,6 +11,7 @@ const registerModuleHooks = async ({ appDir, distDir, baseUrl, paths })=>{
11
11
  process.env.TS_NODE_IGNORE = `(?:^|/)node_modules/,(?:^|/)${node_path.relative(appDir, distDir)}/`;
12
12
  register('./ts-node-loader.mjs', import.meta.url, {
13
13
  data: {
14
+ appDir,
14
15
  baseUrl,
15
16
  paths
16
17
  }
@@ -1,15 +1,11 @@
1
1
  import "node:module";
2
- import { pathToFileURL } from "url";
3
- import { findMatchedSourcePath, findSourceEntry } from "@modern-js/utils";
4
- import { createMatchPath } from "@modern-js/utils/tsconfig-paths";
5
2
  import { load, resolve } from "ts-node/esm";
6
- let matchPath;
7
- async function initialize({ baseUrl, paths }) {
8
- matchPath = createMatchPath(baseUrl || './', paths || {});
3
+ import { initialize, resolve as external_ts_paths_loader_mjs_resolve } from "./ts-paths-loader.mjs";
4
+ async function ts_node_loader_initialize(config) {
5
+ await initialize(config);
9
6
  }
10
7
  function ts_node_loader_resolve(specifier, context, defaultResolve) {
11
- const match = findMatchedSourcePath(matchPath, specifier);
12
- return match ? resolve(pathToFileURL(findSourceEntry(match) || match).href, context, defaultResolve) : resolve(specifier, context, defaultResolve);
8
+ return external_ts_paths_loader_mjs_resolve(specifier, context, (specifier, context)=>resolve(specifier, context, defaultResolve));
13
9
  }
14
10
  function ts_node_loader_load(url, context, defaultLoad) {
15
11
  const filePath = new URL(url).pathname;
@@ -17,4 +13,4 @@ function ts_node_loader_load(url, context, defaultLoad) {
17
13
  if (filePath.includes('node_modules')) return defaultLoad(url, context);
18
14
  return load(url, context, defaultLoad);
19
15
  }
20
- export { initialize, ts_node_loader_load as load, ts_node_loader_resolve as resolve };
16
+ export { ts_node_loader_initialize as initialize, ts_node_loader_load as load, ts_node_loader_resolve as resolve };
@@ -2,7 +2,7 @@ import "node:module";
2
2
  import path from "path";
3
3
  import { findExists, fs } from "@modern-js/utils";
4
4
  import { HTML_PARTIALS_EXTENSIONS, HTML_PARTIALS_FOLDER } from "./constants.mjs";
5
- import * as __rspack_external__templates_mjs_4da4c6c8 from "./templates.mjs";
5
+ import * as __rspack_external__templates_mjs_ab577925 from "./templates.mjs";
6
6
  const findPartials = (dir, entryName, position)=>{
7
7
  if (fs.existsSync(dir)) {
8
8
  const base = findExists(HTML_PARTIALS_EXTENSIONS.map((ext)=>path.resolve(dir, `${position}${ext}`)));
@@ -71,7 +71,7 @@ const getHtmlTemplate = async (entrypoints, hooks, { appContext, config })=>{
71
71
  partials: getModifyHtmlPartials(partials)
72
72
  });
73
73
  const templatePath = path.resolve(internalDirectory, entryName, 'index.html');
74
- fs.outputFileSync(templatePath, __rspack_external__templates_mjs_4da4c6c8.html(partials), 'utf8');
74
+ fs.outputFileSync(templatePath, __rspack_external__templates_mjs_ab577925.html(partials), 'utf8');
75
75
  htmlTemplates[entryName] = templatePath.replace(/\\/g, '/');
76
76
  partialsByEntrypoint[entryName] = partials;
77
77
  const bottomTemplate = findPartials(htmlDir, name, "bottom");
@@ -2,8 +2,8 @@ import "node:module";
2
2
  import fs from "fs";
3
3
  import { parse } from "@babel/parser";
4
4
  import traverse from "@babel/traverse";
5
- import * as __rspack_external__babel_types_69e65b52 from "@babel/types";
6
- const isFunction = (node)=>__rspack_external__babel_types_69e65b52.isFunctionDeclaration(node) || __rspack_external__babel_types_69e65b52.isFunctionExpression(node) || __rspack_external__babel_types_69e65b52.isArrowFunctionExpression(node);
5
+ import * as __rspack_external__babel_types_6e8337dd from "@babel/types";
6
+ const isFunction = (node)=>__rspack_external__babel_types_6e8337dd.isFunctionDeclaration(node) || __rspack_external__babel_types_6e8337dd.isFunctionExpression(node) || __rspack_external__babel_types_6e8337dd.isArrowFunctionExpression(node);
7
7
  const isDefaultExportFunction = (file)=>{
8
8
  if (!file || !fs.existsSync(file)) return false;
9
9
  const ast = parse(fs.readFileSync(file, 'utf8'), {
@@ -1,6 +1,3 @@
1
- export function initialize({ baseUrl, paths }: {
2
- baseUrl: any;
3
- paths: any;
4
- }): Promise<void>;
1
+ export function initialize(config: any): Promise<void>;
5
2
  export function resolve(specifier: any, context: any, defaultResolve: any): any;
6
3
  export function load(url: any, context: any, defaultLoad: any): any;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.8.2",
18
+ "version": "3.9.0",
19
19
  "types": "./dist/types/index.d.ts",
20
20
  "main": "./dist/cjs/index.js",
21
21
  "exports": {
@@ -116,26 +116,26 @@
116
116
  "@babel/parser": "^7.29.7",
117
117
  "@babel/traverse": "^7.29.7",
118
118
  "@babel/types": "^7.29.7",
119
- "@rsbuild/core": "2.1.0",
119
+ "@rsbuild/core": "2.2.0-rc.0",
120
120
  "@swc/core": "1.15.41",
121
121
  "@swc/helpers": "^0.5.17",
122
122
  "es-module-lexer": "^1.7.0",
123
- "flatted": "^3.4.2",
123
+ "flatted": "^3.4.4",
124
124
  "import-meta-resolve": "^4.2.0",
125
125
  "mlly": "^1.8.2",
126
126
  "ndepe": "^0.1.13",
127
127
  "pkg-types": "^1.3.1",
128
128
  "std-env": "^3.10.0",
129
- "@modern-js/builder": "3.8.2",
130
- "@modern-js/i18n-utils": "3.8.2",
131
- "@modern-js/plugin": "3.8.2",
132
- "@modern-js/plugin-data-loader": "3.8.2",
133
- "@modern-js/prod-server": "3.8.2",
134
- "@modern-js/server": "3.8.2",
135
- "@modern-js/server-utils": "3.8.2",
136
- "@modern-js/types": "3.8.2",
137
- "@modern-js/server-core": "3.8.2",
138
- "@modern-js/utils": "3.8.2"
129
+ "@modern-js/builder": "3.9.0",
130
+ "@modern-js/i18n-utils": "3.9.0",
131
+ "@modern-js/plugin-data-loader": "3.9.0",
132
+ "@modern-js/plugin": "3.9.0",
133
+ "@modern-js/prod-server": "3.9.0",
134
+ "@modern-js/server": "3.9.0",
135
+ "@modern-js/server-core": "3.9.0",
136
+ "@modern-js/server-utils": "3.9.0",
137
+ "@modern-js/types": "3.9.0",
138
+ "@modern-js/utils": "3.9.0"
139
139
  },
140
140
  "devDependencies": {
141
141
  "@rslib/core": "0.23.2",
package/rslib.config.mts CHANGED
@@ -19,11 +19,22 @@ export default defineConfig({
19
19
  },
20
20
  output: {
21
21
  ...libConfig.output,
22
+ // `src/esm` is also matched by the `./src/**` entry, so the bundler
23
+ // emits these files itself. The ESM outputs keep the `.mjs` extension,
24
+ // which means bundle and copy write the very same paths — two writers
25
+ // for one file, occasionally leaving it truncated and unparsable, which
26
+ // takes down every `"type": "module"` project. The CJS output emits
27
+ // `.js`, so there the copy is the only thing providing the `.mjs`
28
+ // loaders that `register()` resolves by name; keep it for that alone.
22
29
  copy: [
23
- {
24
- from: './src/esm',
25
- to: './esm',
26
- },
30
+ ...(libConfig.format === 'esm'
31
+ ? []
32
+ : [
33
+ {
34
+ from: './src/esm',
35
+ to: './esm',
36
+ },
37
+ ]),
27
38
  {
28
39
  from: 'plugins/deploy/platforms/templates/*.cjs',
29
40
  context: path.join(__dirname, 'src'),