@astral/pack 2.0.0 → 2.0.2

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/README.md CHANGED
@@ -44,12 +44,13 @@ module.exports = defineConfig({
44
44
  ```json
45
45
  {
46
46
  "exports": {
47
- "./components/Button": "./components/Button/index.js"
47
+ "./components/Button": "./src/components/Button/index.ts",
48
+ "./components/Input": "./src/components/Button/index.tsx"
48
49
  }
49
50
  }
50
51
  ```
51
52
 
52
- Строковые экспорты автоматически расширяются в полные объекты с учетом настроек `format` и `lang` из `pack.config.js`:
53
+ Строковые экспорты автоматически расширяются в полные объекты с учетом настроек `format` и `lang` из `pack.config.js`. Директория 'src' убирается из финального пути.
53
54
  ```json
54
55
  {
55
56
  "exports": {
@@ -66,6 +67,13 @@ module.exports = defineConfig({
66
67
  "types": "./components/Button/index.d.ts",
67
68
  "default": "./components/Button/index.js",
68
69
  "import": "./components/Button/index.js"
70
+ },
71
+ "./components/Input": {
72
+ "module": "./components/Input/index.js",
73
+ "require": "./node/components/Input/index.js",
74
+ "types": "./components/Input/index.d.ts",
75
+ "default": "./components/Input/index.js",
76
+ "import": "./components/Input/index.js"
69
77
  }
70
78
  }
71
79
  }
@@ -138,12 +146,12 @@ pack create-release
138
146
  {
139
147
  "exports": {
140
148
  "./server": "./server/index.js",
141
- "./components/Button": "./components/Button/index.js"
149
+ "./components/Button": "./src/components/Button/index.tsx"
142
150
  }
143
151
  }
144
152
  ```
145
153
 
146
- Строковые экспорты автоматически расширяются в полные объекты с учетом настроек `format` и `lang`:
154
+ Строковые экспорты автоматически расширяются в полные объекты с учетом настроек `format` и `lang`. Директория 'src' убирается из финального пути.
147
155
  ```json
148
156
  {
149
157
  "exports": {
@@ -160,6 +168,13 @@ pack create-release
160
168
  "types": "./server/index.d.ts",
161
169
  "default": "./server/index.js",
162
170
  "import": "./server/index.js"
171
+ },
172
+ "./components/Button": {
173
+ "module": "./components/Button/index.js",
174
+ "require": "./node/components/Button/index.js",
175
+ "types": "./components/Button/index.d.ts",
176
+ "default": "./components/Button/index.js",
177
+ "import": "./components/Button/index.js"
163
178
  }
164
179
  }
165
180
  }
@@ -44,21 +44,21 @@ const initUpdatingReleaseGroup = (config, packageVersion) => (originPackageJson)
44
44
  */
45
45
  const expandStringExport = (value, format, lang) => {
46
46
  const exportItem = {};
47
+ const jsPath = value.replace('/src', '').replace(/\.(ts|tsx|jsx)$/, '.js');
47
48
  if (format.includes('esm')) {
48
- exportItem.module = value;
49
+ exportItem.module = jsPath;
49
50
  }
50
51
  if (format.includes('cjs')) {
51
52
  // Добавляем ./node/ перед путем для require
52
- exportItem.require = value.startsWith('./')
53
- ? `./node/${value.slice(2)}`
54
- : `./node/${value}`;
53
+ exportItem.require = jsPath.startsWith('./')
54
+ ? `./node/${jsPath.slice(2)}`
55
+ : `./node/${jsPath}`;
55
56
  }
56
57
  if (lang === 'ts') {
57
- // Заменяем .js на .d.ts для типов
58
- exportItem.types = value.replace(/\.js$/, '.d.ts');
58
+ exportItem.types = jsPath.replace(/\.js$/, '.d.ts');
59
59
  }
60
- exportItem.default = value;
61
- exportItem.import = value;
60
+ exportItem.default = jsPath;
61
+ exportItem.import = jsPath;
62
62
  return exportItem;
63
63
  };
64
64
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/pack",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "main": "./index.js",
5
5
  "bin": {
6
6
  "pack": "bin.js"