Skip to content

Commit

Permalink
Release 3.0.0 (#27)
Browse files Browse the repository at this point in the history
## Release notes
* Visyn core (#24)
* Check if it is a workspace when reading tsconfig
(#26)


### Release dependencies first

In case of dependent Phovea/TDP repositories follow [dependency
tree](https://wiki.datavisyn.io/phovea/fundamentals/development-process#dependency-hierarchy)
from the top:

 
### 🏁 Finish line

* [ ] Inform colleagues and customers about the release
* [ ] Celebrate the new release 🥳
  • Loading branch information
dvvanessastoiber authored Mar 1, 2023
2 parents 86a0f11 + 4114c26 commit 43d8dee
Show file tree
Hide file tree
Showing 10 changed files with 1,180 additions and 3,362 deletions.
6 changes: 2 additions & 4 deletions bin/commands/docs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const { call } = require('./utils');

module.exports = {
command: 'docs [strings...]',
describe: 'Generate docs of a repository using typedoc',
handler: (args) => {
call('typedoc', `--options ./typedoc.js ${(args.strings || []).join(' ')} src/**.ts`);
handler: () => {
console.log('No docs integration yet...');
},
};
41 changes: 14 additions & 27 deletions config/jest.config.template.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,34 @@
// test dependencies that require transformation
let pluginsToTransform = [
// datavisyn
'tdp_*',
'phovea_*',
'lineupjs',
// d3
'd3-*',
'internmap',
'delaunator',
'robust-predicates',
const pluginsNotToTransform = [
// Disable the transform for d3v3, as it otherwise leads to "Cannot read property 'document' of undefined": https://stackoverflow.com/a/35560440
'd3v3',
].join('|');

if (pluginsToTransform.length > 0) {
/** Attention: Negative Lookahead! This regex adds the specified repos to a
* whitelist that holds plugins that are excluded from the transformIgnorePatterns.
* This means that pluginsToTransform should contain all repos that export ts files.
* They can only be handled by the transformation. */
pluginsToTransform = `(?!${pluginsToTransform})`;
}

/**
* TODO check if we can process inline webpack loaders (e.g. as found in https://github.com/phovea/phovea_ui/blob/master/src/_bootstrap.ts)
* see also https://jestjs.io/docs/en/webpack#mocking-css-modules
*/
module.exports = {
testEnvironment: 'jsdom',
transform: {
'^.+\\.(js|ts|tsx)$': 'ts-jest',
'^.+\\.(js|ts|tsx|mjs|mts)$': ['@swc/jest', {
// Exactly the same configuration as in the webpack.config.js
jsc: {
parser: {
syntax: 'typescript',
decorators: true,
},
},
}],
'\\.xml$': 'jest-raw-loader',
},
testRegex: '(.*(test|spec))\\.(tsx?)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
modulePaths: ['src'],
transformIgnorePatterns: [`../node_modules/${pluginsToTransform}`, `node_modules/${pluginsToTransform}`],
resolver: 'visyn_scripts/config/jest_export_maps_resolver.js',
transformIgnorePatterns: [`../node_modules/${pluginsNotToTransform}`, `node_modules/${pluginsNotToTransform}`],
globals: {
__VERSION__: 'TEST_VERSION',
__APP_CONTEXT__: 'TEST_CONTEXT',
'ts-jest': {
// has to be set to true, otherwise i18n import fails
tsconfig: {
esModuleInterop: true,
},
},
},
moduleNameMapper: {
'^.+\\.(css|less|scss|sass|png|jpg|gif|svg|html)$': 'identity-obj-proxy',
Expand Down
8 changes: 8 additions & 0 deletions config/jest_export_maps_resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// temporary workaround while we wait for https://github.com/facebook/jest/issues/9771
// eslint-disable-next-line import/no-extraneous-dependencies
const resolver = require('enhanced-resolve').create.sync({
conditionNames: ['require', 'node', 'default', 'import'],
extensions: ['.js', '.json', '.node', '.ts', '.tsx'],
});

module.exports = (request, options) => resolver(options.basedir, request);
4 changes: 2 additions & 2 deletions config/tsconfig.template.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"compilerOptions": {
"module": "ES2020",
"module": "ESNext",
"target": "ES2021",
"importHelpers": true,
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"moduleResolution": "node",
"moduleResolution": "node16",
"jsx": "react",
"allowJs": true,
"experimentalDecorators": true,
Expand Down
7 changes: 0 additions & 7 deletions config/typedoc.template.js

This file was deleted.

31 changes: 26 additions & 5 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
const dotenv = require('dotenv');
const dotenvExpand = require('dotenv-expand');
const { parseTsconfig } = require('get-tsconfig');

let jquery = null;
try {
jquery = require.resolve('jquery');
} catch {
// pass
}

// const { TimeAnalyticsPlugin } = require('time-analytics-webpack-plugin');

// Load the current .env and expand it
Expand Down Expand Up @@ -134,6 +143,12 @@ module.exports = (webpackEnv, argv) => {
entries = {};
}

const tsconfigJson = isSingleRepoMode ? parseTsconfig(path.join(workspacePath, 'tsconfig.json')) : null;
const isLegacyModuleResolution = tsconfigJson?.compilerOptions?.moduleResolution?.toLowerCase() === 'node';
if (isLegacyModuleResolution) {
console.warn('visyn user: you are still using moduleResolution: node. Try to upgrade to node16 as soon as possible!');
}

const copyAppFiles = copyFiles?.map((file) => ({
from: path.join(defaultAppPath, file),
to: path.join(workspacePath, 'bundles', path.basename(file)),
Expand Down Expand Up @@ -286,7 +301,7 @@ module.exports = (webpackEnv, argv) => {
entry: Object.fromEntries(
Object.entries(entries).map(([key, entry]) => [
key,
[workspaceRegistryFile, path.join(defaultAppPath, entry.js), entry.scss ? path.join(defaultAppPath, entry.scss) : './workspace.scss'],
[workspaceRegistryFile, path.join(defaultAppPath, entry.js), entry.scss ? path.join(defaultAppPath, entry.scss) : './workspace.scss'].filter((v) => fs.existsSync(v)),
]),
),
devServer: isEnvDevelopment
Expand Down Expand Up @@ -380,6 +395,12 @@ module.exports = (webpackEnv, argv) => {
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
// This is required to enable TS moduleResolution: node16, as there we have to add .js extensions which are actually .ts files.
extensionAlias: isLegacyModuleResolution ? undefined : {
'.js': ['.tsx', '.ts', '.js'],
'.cjs': ['.cts', '.cjs'],
'.mjs': ['.mts', '.mjs'],
},
// By default, always search for modules in the relative node_modules. However,
// if the package can not be found, fall back to the workspace node_modules. This is
// useful when using the resolveAliases to resolve a package to somewhere else.
Expand Down Expand Up @@ -578,13 +599,13 @@ module.exports = (webpackEnv, argv) => {
],
},
// TODO: Is this legacy stuff, should it be included as well?
{
test: require.resolve('jquery'),
jquery ? {
test: jquery,
loader: 'expose-loader',
options: {
exposes: ['window.jQuery', '$'],
},
},
} : null,
// "file" loader makes sure those assets get served by WebpackDevServer.
// When you `import` an asset, you get its (virtual) filename.
// In production, they would get copied to the `build` folder.
Expand All @@ -600,7 +621,7 @@ module.exports = (webpackEnv, argv) => {
},
// ** STOP ** Are you adding a new loader?
// Make sure to add the new loader(s) before the "file" loader.
],
].filter(Boolean),
},
].filter(Boolean),
},
Expand Down
39 changes: 8 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "visyn_scripts",
"description": "",
"version": "2.0.0",
"version": "3.0.0",
"author": {
"name": "datavisyn GmbH",
"email": "[email protected]",
Expand Down Expand Up @@ -32,38 +32,23 @@
"dist": "npm run lint && npm run test"
},
"dependencies": {
"@babel/core": "^7.16.0",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-decorators": "^7.17.9",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.6.3",
"@babel/preset-react": "^7.6.3",
"@babel/preset-typescript": "^7.6.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
"@svgr/webpack": "^5.5.0",
"@swc/core": "1.3.30",
"@swc/core": "~1.3.35",
"@swc/jest": "~0.2.24",
"@types/jest": "~27.4.1",
"@types/jquery": "^3.5.5",
"@types/node": "^17.0.24",
"@types/webpack": "^5.28.0",
"@types/yeoman-environment": "2",
"@types/yeoman-generator": "4",
"@typescript-eslint/eslint-plugin": "~5.42.0",
"@typescript-eslint/parser": "~5.42.0",
"babel-jest": "^27.4.2",
"babel-loader": "^8.2.3",
"babel-plugin-named-asset-import": "^0.3.8",
"babel-preset-react-app": "^10.0.1",
"bfj": "^7.0.2",
"@typescript-eslint/eslint-plugin": "~5.52.0",
"@typescript-eslint/parser": "~5.52.0",
"bluebird": "3",
"browserslist": "^4.18.1",
"camelcase": "^6.2.1",
"case-sensitive-paths-webpack-plugin": "^2.4.0",
"chalk": "4",
"child-process-promise": "^2.2.1",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^10.2.4",
"core-js": "^2.6.5",
"cross-spawn": "^7.0.3",
"css-loader": "^6.5.1",
"css-minimizer-webpack-plugin": "^3.2.0",
Expand All @@ -78,7 +63,7 @@
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-chai-friendly": "^0.7.2",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^25.3.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
Expand All @@ -89,6 +74,7 @@
"file-loader": "^6.2.0",
"fork-ts-checker-webpack-plugin": "^7.2.6",
"fs-extra": "^10.0.0",
"get-tsconfig": "^4.4.0",
"glob": "^8.0.3",
"html-loader": "~1.3.2",
"html-webpack-plugin": "^5.5.0",
Expand All @@ -99,21 +85,16 @@
"jest": "^27.4.3",
"jest-raw-loader": "~1.0.1",
"jest-resolve": "^27.4.2",
"jest-watch-typeahead": "^1.0.0",
"jquery": "~3.5.1",
"lodash": "^4.17.21",
"mini-css-extract-plugin": "^2.4.5",
"npm-run-all": "^4.1.5",
"npm-watch": "~0.11.0",
"postcss": "^8.4.4",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-loader": "^6.2.1",
"postcss-normalize": "^10.0.1",
"postcss-preset-env": "^7.0.1",
"prettier": "^2.5.1",
"prompts": "^2.4.2",
"raw-loader": "~4.0.2",
"react-app-polyfill": "^3.0.0",
"react-dev-utils": "^12.0.1",
"react-refresh": "^0.11.0",
"resolve": "^1.20.0",
Expand All @@ -134,17 +115,13 @@
"ts-jest": "~27.1.3",
"ts-node": "^10.7.0",
"tslib": "~2.3.1",
"type-fest": "^2.12.2",
"typedoc": "~0.22.13",
"typescript": "~4.6.2",
"typescript": "~4.9.5",
"url-loader": "~4.1.1",
"util": "^0.12.4",
"webpack": "^5.64.4",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.6.0",
"webpack-manifest-plugin": "^4.0.2",
"workbox-webpack-plugin": "^6.4.1",
"yamljs": "^0.3.0",
"yargs": "^17.5.1",
"yeoman-environment": "2",
Expand Down
1 change: 0 additions & 1 deletion tests_fixtures/standalone_template/typedoc.js

This file was deleted.

Loading

0 comments on commit 43d8dee

Please sign in to comment.