Skip to content

Commit

Permalink
Merge pull request #296 from sima-land/295-exports-field
Browse files Browse the repository at this point in the history
#295 Добавить поле "exports" в package.json
  • Loading branch information
krutoo authored Oct 1, 2024
2 parents 17ba570 + 7364fca commit da3b4c7
Show file tree
Hide file tree
Showing 30 changed files with 104 additions and 38 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# library build
build
temp

# misc
.DS_Store
Expand All @@ -27,4 +28,4 @@ yarn-debug.log*
yarn-error.log*

# npm pack default output
sima-land-moleculas-0.0.0.tgz
sima-land-moleculas-0.0.0.tgz
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 35 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
},
"scripts": {
"prepare": "husky",
"build": "npm run build:clean && npm run build:scripts && npm run build:assets && npm run build:package",
"build": "npm run build:sync-exports && npm run build:clean && npm run build:scripts && npm run build:assets && npm run build:package",
"build:clean": "rm -rf build",
"build:scripts": "tsc --project tsconfig.build.json",
"build:assets": "node scripts/build-assets.mjs",
"build:assets": "node scripts/copy-assets.mjs",
"build:package": "cd build && npm pkg delete scripts.prepare && cd ..",
"build:sync-exports": "node scripts/emit-exports.mjs && npm pkg set --json exports=\"$(cat ./temp/exports.json)\" && rm -rf temp/exports.json",
"type-check": "tsc -p . --noEmit",
"lint": "npm run lint:scripts && npm run lint:styles",
"lint:scripts": "eslint src",
Expand Down Expand Up @@ -57,8 +58,39 @@
"typescript": "^5.3.3"
},
"peerDependencies": {
"@sima-land/ui-nucleons": "^45.0.0-alpha.24",
"@sima-land/ui-nucleons": "^45.0.0-alpha.25",
"@sima-land/ui-quarks": "^5.1.1",
"react": "^17.0 || ^18.0"
},
"exports": {
"./common/components/badge-list": "./common/components/badge-list/index.js",
"./common/components/badge": "./common/components/badge/index.js",
"./common/components/breadcrumbs": "./common/components/breadcrumbs/index.js",
"./common/components/hover-slider": "./common/components/hover-slider/index.js",
"./common/components/img-stub": "./common/components/img-stub/index.js",
"./common/components/interactive-image": "./common/components/interactive-image/index.js",
"./common/components/interactive-image/interactive-image-util.scss": "./common/components/interactive-image/interactive-image-util.scss",
"./common/components/media-gallery": "./common/components/media-gallery/index.js",
"./common/components/media-modal": "./common/components/media-modal/index.js",
"./common/components/modifier": "./common/components/modifier/index.js",
"./common/components/pagination-controls": "./common/components/pagination-controls/index.js",
"./common/components/product-image": "./common/components/product-image/index.js",
"./common/components/product-info": "./common/components/product-info/index.js",
"./common/components/rating-counter": "./common/components/rating-counter/index.js",
"./common/components/rating-counter/rating-counter-util.scss": "./common/components/rating-counter/rating-counter-util.scss",
"./common/hooks": "./common/hooks/index.js",
"./desktop/components/breadcrumbs": "./desktop/components/breadcrumbs/index.js",
"./desktop/components/gallery-modal": "./desktop/components/gallery-modal/index.js",
"./desktop/components/person-info": "./desktop/components/person-info/index.js",
"./desktop/components/product-carousel": "./desktop/components/product-carousel/index.js",
"./desktop/components/promotion-card": "./desktop/components/promotion-card/index.js",
"./mobile/components/action-circles": "./mobile/components/action-circles/index.js",
"./mobile/components/action-list": "./mobile/components/action-list/index.js",
"./mobile/components/breadcrumbs": "./mobile/components/breadcrumbs/index.js",
"./mobile/components/person-info": "./mobile/components/person-info/index.js",
"./mobile/components/product-row": "./mobile/components/product-row/index.js",
"./mobile/components/product-slider": "./mobile/components/product-slider/index.js",
"./mobile/components/search-bar": "./mobile/components/search-bar/index.js",
"./mobile/components/select-screen": "./mobile/components/select-screen/index.js"
}
}
2 changes: 1 addition & 1 deletion scripts/build-assets.mjs → scripts/copy-assets.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable require-jsdoc, jsdoc/require-jsdoc */
/* eslint-disable jsdoc/require-jsdoc */
import copyfiles from 'copyfiles';

function copy(paths, options = {}) {
Expand Down
33 changes: 33 additions & 0 deletions scripts/emit-exports.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import glob from 'fast-glob';

const paths = await glob(
[
//
'./src/{common,desktop,mobile}/components/*/index.{js,jsx,ts,tsx}',
'./src/{common,desktop,mobile}/hooks/index.{js,jsx,ts,tsx}',
'./src/**/*.scss',
],
{
ignore: [
//
'./src/**/*.m.scss',
'./src/**/_*.scss',
],
},
);

const data = Object.fromEntries(
paths
.sort()
.map(p => [
`./${path.relative('src', p).replace(/\/index\.(js|jsx|ts|tsx)$/g, '')}`,
`./${path.relative('src', p).replace(/\.(js|jsx|ts|tsx)$/g, '.js')}`,
]),
);

const outputPath = path.resolve(process.cwd(), 'temp/exports.json');

await fs.mkdir(path.dirname(outputPath), { recursive: true });
await fs.writeFile(outputPath, JSON.stringify(data, null, 2), 'utf-8');
2 changes: 1 addition & 1 deletion src/common/components/badge/badge.m.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use 'pkg:@sima-land/ui-nucleons/utils';
@use 'pkg:@sima-land/ui-nucleons/utils.scss';

$badge-size: 20px;
$icon-size: 16px;
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/hover-slider/hover-slider.m.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/utils';
@use 'pkg:@sima-land/ui-nucleons/utils.scss';

.root {
position: relative;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';

@mixin dot-size-default {
--dot-size: 32px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
@use './interactive-image-util';

.root {
Expand Down
4 changes: 2 additions & 2 deletions src/common/components/media-modal/layout.m.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/utils';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
@use 'pkg:@sima-land/ui-nucleons/utils.scss';

.layout {
display: flex;
Expand Down
4 changes: 2 additions & 2 deletions src/common/components/media-modal/parts/parts.m.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/utils';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
@use 'pkg:@sima-land/ui-nucleons/utils.scss';

.header-layout {
min-height: 40px; // ВАЖНО: чтобы при отсутствии табов не уменьшалась высота
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/media-modal/parts/review.m.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
@use 'pkg:@sima-land/ui-nucleons/colors.scss';

.root {
Expand Down
4 changes: 2 additions & 2 deletions src/common/components/media-modal/parts/scroll-section.m.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/utils';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
@use 'pkg:@sima-land/ui-nucleons/utils.scss';

.inner {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/media-modal/parts/thumbnail.m.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';

.root {
display: block;
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/media-modal/parts/thumbnails.m.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use 'pkg:@sima-land/ui-nucleons/utils';
@use 'pkg:@sima-land/ui-nucleons/utils.scss';

.list-desktop {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/utils';
@use 'pkg:@sima-land/ui-nucleons/utils.scss';

.layout {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';

.root {
width: 24px;
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/product-info/parts/parts.m.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';

.text-button {
font-size: 14px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
@use '../../rating-counter/rating-counter-util';

.root {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';

.root {
font-size: 14px;
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/rating-counter/rating-counter.m.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
@use './rating-counter-util';

.root {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/utils';
@use 'pkg:@sima-land/ui-nucleons/utils.scss';

.root {
position: absolute;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
@use 'pkg:@sima-land/ui-nucleons/colors.scss';

$breakpoints: 'xs', 's', 'm', 'l', 'xl';
Expand Down
2 changes: 1 addition & 1 deletion src/desktop/components/promotion-card/placeholder.m.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use './variables';
@use './_variables';

.part {
background: colors.$basic-gray4;
Expand Down
6 changes: 3 additions & 3 deletions src/desktop/components/promotion-card/promotion-card.m.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/shadows';
@use './variables';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
@use 'pkg:@sima-land/ui-nucleons/shadows.scss';
@use './_variables';

.root {
background: #fff;
Expand Down
2 changes: 1 addition & 1 deletion src/mobile/components/action-circles/action-circles.m.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/utils';
@use 'pkg:@sima-land/ui-nucleons/utils.scss';

.circles {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/mobile/components/action-list/action-list.m.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
@use 'pkg:@sima-land/ui-nucleons/utils';
@use 'pkg:@sima-land/ui-nucleons/utils.scss';

.circles {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/mobile/components/product-slider/product-slider.m.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';

.item {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/mobile/components/select-screen/select-screen.m.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use 'pkg:@sima-land/ui-nucleons/breakpoints';
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
@use 'pkg:@sima-land/ui-nucleons/colors.scss';

.container {
Expand Down

0 comments on commit da3b4c7

Please sign in to comment.