Skip to content

Commit

Permalink
Resolves #1985
Browse files Browse the repository at this point in the history
The previous commit changed the config from CJS to ESM which caused
2 tests to fail.
This commit fixes the above issue by replacing 'require' with 'import'
throughout the project

Signed-off-by: shivam <[email protected]>
  • Loading branch information
ShivamMadlani committed Nov 23, 2023
1 parent 5559770 commit d774447
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/jaeger-ui/test/babel-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const babelJest = require('babel-jest').default;
import babelJest from 'babel-jest';

const babelConfiguration = {
presets: [
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/test/generic-file-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const path = require('path');
import path from 'path';

// Simple Jest transform that stubs out CSS files and returns the file name as the mock content for other file types.
module.exports = {
Expand Down
6 changes: 3 additions & 3 deletions packages/jaeger-ui/test/jest-per-test-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ rafPolyfill();
global.TextEncoder = TextEncoder;

/* eslint-disable import/no-extraneous-dependencies */
const Enzyme = require('enzyme');
const EnzymeAdapter = require('@wojtekmaj/enzyme-adapter-react-17');
const createSerializer = require('enzyme-to-json').createSerializer;
import Enzyme from 'enzyme';
import EnzymeAdapter from '@wojtekmaj/enzyme-adapter-react-17';
import { createSerializer } from 'enzyme-to-json';

Enzyme.configure({ adapter: new EnzymeAdapter() });
expect.addSnapshotSerializer(createSerializer({ mode: 'deep' }));
Expand Down
9 changes: 4 additions & 5 deletions packages/plexus/webpack-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable @typescript-eslint/no-var-requires */

const { join } = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
import { join } from 'path';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import nodeExternals from 'webpack-node-externals';

const babelConfigPath = require.resolve('./babel.config');

Expand Down
2 changes: 1 addition & 1 deletion packages/plexus/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
// limitations under the License.

// eslint-disable-next-line @typescript-eslint/no-var-requires
const factory = require('./webpack-factory');
import factory from './webpack-factory';

module.exports = factory('development');
2 changes: 1 addition & 1 deletion packages/plexus/webpack.layout-worker.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
// limitations under the License.

// eslint-disable-next-line @typescript-eslint/no-var-requires
const factory = require('./webpack-factory');
import factory from './webpack-factory';

module.exports = factory('layout-worker');
2 changes: 1 addition & 1 deletion packages/plexus/webpack.umd.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
// limitations under the License.

// eslint-disable-next-line @typescript-eslint/no-var-requires
const factory = require('./webpack-factory');
import factory from './webpack-factory';

module.exports = factory('umd');
6 changes: 3 additions & 3 deletions scripts/generateDepcheckrcJaegerUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const { babelConfiguration } = require('../packages/jaeger-ui/test/babel-transform');
import fs from 'fs';
import path from 'path';
import { babelConfiguration } from '../packages/jaeger-ui/test/babel-transform';

const packageNames = [
...babelConfiguration.presets.flatMap(preset => {
Expand Down
6 changes: 3 additions & 3 deletions scripts/generateDepcheckrcPlexus.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const getBabelConfig = require('../packages/plexus/babel.config');
import fs from 'fs';
import path from 'path';
import getBabelConfig from '../packages/plexus/babel.config';

const babelConfiguration = getBabelConfig({
env: () => {
Expand Down

0 comments on commit d774447

Please sign in to comment.