Skip to content

Commit

Permalink
fix: fix types importing in root package (#569)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Yatsenko <reme3d2y@gmail.com>
  • Loading branch information
dmitrsavk and reme3d2y committed Mar 19, 2021
1 parent 0e0b2d3 commit bdb362a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"@types/react-dom": "^16.9.5",
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0",
"@wessberg/rollup-plugin-ts": "^1.3.6",
"@wessberg/rollup-plugin-ts": "^1.3.8",
"arui-presets-lint": "4.1.1",
"arui-presets-ts": "^5.0.0",
"axios": "^0.21.0",
Expand Down
8 changes: 5 additions & 3 deletions tools/rollup/core-components-typings-resolver.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import globby from 'globby';
import path from 'path';

import { checkOrCreateDir, readFile, requireRegExp, writeFile } from './common';
import { checkOrCreateDir, readFile, writeFile } from './common';

const importTypesRegexp = /((?:from |import\()['"])@alfalab\/core-components-(.+?)(['"])/;

async function transformTypings(source, rootDir) {
const rootAbsDir = path.resolve(rootDir);
Expand All @@ -11,12 +13,12 @@ async function transformTypings(source, rootDir) {

let matches;

while ((matches = requireRegExp.exec(fileContent))) {
while ((matches = importTypesRegexp.exec(fileContent))) {
const componentName = matches[2];

const componentRelativePath = path.relative(path.dirname(sourceAbs), componentName);

fileContent = fileContent.replace(requireRegExp, `$1${componentRelativePath}$3`);
fileContent = fileContent.replace(importTypesRegexp, `$1${componentRelativePath}$3`);
}

let dest = path.join(rootAbsDir, source.replace('dist/', ''));
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4690,7 +4690,7 @@
semver "^7.3.2"
ua-parser-js "^0.7.22"

"@wessberg/rollup-plugin-ts@^1.3.6":
"@wessberg/rollup-plugin-ts@^1.3.8":
version "1.3.8"
resolved "https://registry.yarnpkg.com/@wessberg/rollup-plugin-ts/-/rollup-plugin-ts-1.3.8.tgz#90c8d091006fa83c117449ba51a49ec07f0b5797"
integrity sha512-mqAk8CS5VbeE1eMRwbBkrVWqrqDxRJEWfxPHFyncsoamoazZ7iJ4Fke7tYBki+x25dw0rkN6l3VgtICM7o//cw==
Expand Down

0 comments on commit bdb362a

Please sign in to comment.