Skip to content

Commit

Permalink
some import alias resolution support
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethbruskiewicz committed Nov 7, 2023
1 parent e1591f7 commit a0406f2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/DataHarmonizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import fieldDescriptionsModal from '@/lib/fieldDescriptionsModal.html';

import HelpSidebar from '@/lib/HelpSidebar';

import pkg from '@/package.json';
// NOTE: this is odd! package.json is a developer file. why should a UI component care about it?
import pkg from '../package.json';
const VERSION = pkg.version;
const VERSION_TEXT = 'DataHarmonizer v' + VERSION;

Expand Down
2 changes: 1 addition & 1 deletion lib/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import template from '@/lib/toolbar.html';
import '@/lib//toolbar.css';

// NOTE: this is odd! package.json is a developer file. why should a UI component care about it?
import pkg from '@/package.json';
import pkg from '../package.json';
const VERSION = pkg.version;

class Toolbar {
Expand Down
9 changes: 9 additions & 0 deletions lib/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { string } from 'rollup-plugin-string';
import image from '@rollup/plugin-image';
import { babel } from '@rollup/plugin-babel';

import alias from '@rollup/plugin-alias';
import path from 'path';

export default {
input: 'lib/index.js',
output: [
Expand All @@ -32,6 +35,12 @@ export default {
json(),
nodeResolve(),
image(),
alias({
entries: [
// Replace '@/lib' with the actual path to the 'lib' directory
{ find: '@/lib', replacement: path.resolve(__dirname, '.') },
],
}),
string({
include: '**/*.html',
}),
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function getNestedValue(obj, path) {
*
* @param {Object} obj - The source object to flatten.
* @returns {Object} - The flattened object representation.
*
*
* @example
* // Simple Nested Object
* const person = {
Expand Down Expand Up @@ -177,10 +177,10 @@ function stringifyNestedVocabulary(vocab_list) {
let flatVocab = flattenObject(vocab_list); // Assuming flattenObject is appropriately modified

// Then, transform the flattened vocabulary into a string representation
return Object.keys(flatVocab).map(key => {
return Object.keys(flatVocab).map((key) => {
// Determine the depth by counting the dots in the key
const level = (key.match(/\./g) || []).length;
// Replace the dots with two spaces for each level of depth
return ' '.repeat(level) + flatVocab[key];
});
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@babel/cli": "^7.18.10",
"@babel/core": "^7.18.10",
"@babel/preset-env": "^7.18.10",
"@rollup/plugin-alias": "^5.0.1",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-image": "^2.1.1",
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,13 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@rollup/plugin-alias@^5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-5.0.1.tgz#c84a43e021f5e0ebf1cc3c5af518c8371251bb77"
integrity sha512-JObvbWdOHoMy9W7SU0lvGhDtWq9PllP5mjpAy+TUslZG/WzOId9u80Hsqq1vCUn9pFJ0cxpdcnAv+QzU2zFH3Q==
dependencies:
slash "^4.0.0"

"@rollup/plugin-babel@^5.3.1":
version "5.3.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283"
Expand Down

0 comments on commit a0406f2

Please sign in to comment.