Skip to content

fix: resolve file modification errors in UI during yarn dev and yarn watch:ds-ext #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
import { ItemValue, ItemWithParams, StringableParam } from '@data-story/core';
import { ItemValue, ItemWithParams, parseStringList, StringableParam } from '@data-story/core';
import { DataStoryNodeData } from '../ReactFlowNode';
import { parseStringList } from '../../../../../core/src/utils/parseStringList';

export function getFormatterOnlyAndDropParamOLD(items: ItemValue[], data: DataStoryNodeData):{ only: string[], drop: string[], destructObjects: boolean } {
export function getFormatterOnlyAndDropParamOLD(items: ItemValue[], data: DataStoryNodeData): {
only: string[],
drop: string[],
destructObjects: boolean
} {
const paramEvaluator = new ItemWithParams(items, data.params, []);
let only: string[] = [], drop: string[] = [];
let destructObjects = true;
try {
only = paramEvaluator.params?.only as string[] ?? [];
drop = paramEvaluator.params?.drop as string[] ?? [];
destructObjects = paramEvaluator.params?.destructObjects === 'false' ? false : true;
} catch(e) {
} catch (e) {
}
return { only, drop, destructObjects };
}

export function getFormatterOnlyAndDropParam(items: ItemValue[], data: DataStoryNodeData): { only: string[], drop: string[], destructObjects: boolean } {
export function getFormatterOnlyAndDropParam(items: ItemValue[], data: DataStoryNodeData): {
only: string[],
drop: string[],
destructObjects: boolean
} {
const onlyParam = data.params.find(param => param.name === 'only') as StringableParam | undefined;
const dropParam = data.params.find(param => param.name === 'drop') as StringableParam | undefined;
const destructObjectsParam = data.params.find(param => param.name === 'destructObjects') as StringableParam | undefined;

return {
only: (() => {
if(onlyParam === undefined) return [];
if (onlyParam === undefined) return [];
return parseStringList(onlyParam?.input?.rawValue);
})(),
drop: (() => {
if(dropParam === undefined) return [];
if (dropParam === undefined) return [];
return parseStringList(dropParam?.input?.rawValue);
})(),
destructObjects: (() => {
if (destructObjectsParam === undefined) return true;
return destructObjectsParam.input?.rawValue !== 'false';
})(),
}
}
};
}
23 changes: 14 additions & 9 deletions packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,29 @@
"allowSyntheticDefaultImports": true,
"incremental": true,
"noImplicitAny": false,
"types": ["node", "react", "cypress"],
"types": [
"node",
"react",
"cypress"
],
"sourceMap": true
},
"ts-node": {
"compilerOptions": {
"module": "CommonJS",
"target": "ESNext"
"target": "ESNext"
}
},
"include": [
"**/*.ts",
"**/*.tsx",
"**/**/*.ts",
"../cypress.d.ts"
],
"exclude": [
"node_modules",
"dist",
"cypress.config.ts",
],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.test.json"
}
]
}
38 changes: 38 additions & 0 deletions packages/ui/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"compilerOptions": {
"target": "ES6",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"declaration": true,
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist",
"esModuleInterop": true,
"module": "ESNext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"allowSyntheticDefaultImports": true,
"incremental": true,
"noImplicitAny": false,
"types": [
"react"
],
"sourceMap": true,
"composite": true
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": [
"./src/**/*.cy.tsx",
"./src/**/*.cy.ts"
]
}
37 changes: 37 additions & 0 deletions packages/ui/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"compilerOptions": {
"target": "ES6",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"declaration": true,
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist",
"esModuleInterop": true,
"module": "ESNext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"allowSyntheticDefaultImports": true,
"incremental": true,
"noImplicitAny": false,
"types": ["node", "react", "cypress"],
"sourceMap": true,
"composite": true
},
"include": [
"../cypress.d.ts",
"./cypress-webpack.config.ts"
],
"exclude": [
"node_modules",
"dist",
"cypress.config.ts",
]
}
13 changes: 10 additions & 3 deletions packages/ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const dependencies = require('./package.json').dependencies;

const externalsDeps = Object.keys(dependencies);

const webpackCleanKeep = /(data-story.css)|(bundle.[mc]js(\.map|\.LICENSE.txt)?)|(src\/)/;
const commonJSConfig = (env, options) => ({
devtool: 'source-map',
mode: 'development',
Expand All @@ -13,7 +14,7 @@ const commonJSConfig = (env, options) => ({
filename: 'bundle.cjs',
libraryTarget: 'commonjs2',
clean: {
keep: /(data-story.css)|(bundle.mjs(\.map|\.LICENSE.txt)?)/,
keep: webpackCleanKeep,
},
},
module: {
Expand Down Expand Up @@ -49,7 +50,7 @@ const esmConfig = (env, options) => ({
filename: 'bundle.mjs',
libraryTarget: 'module',
clean: {
keep: /(data-story.css)|(bundle.cjs(\.map|\.LICENSE.txt)?)/,
keep: webpackCleanKeep,
},
library: {
type: 'module',
Expand All @@ -59,7 +60,13 @@ const esmConfig = (env, options) => ({
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
use: {
loader: 'ts-loader',
options: {
configFile: path.resolve(__dirname, 'tsconfig.lib.json'),
projectReferences: true,
},
},
exclude: '/node_modules/',
},
{
Expand Down