Skip to content

Commit b2567f3

Browse files
committed
First commit for the ES Module changes
1 parent 7b03340 commit b2567f3

File tree

19 files changed

+31450
-170
lines changed

19 files changed

+31450
-170
lines changed
File renamed without changes.
File renamed without changes.

.storybook/main.js

Lines changed: 77 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
const path = require('path');
2-
const PATHS = require('../config/paths');
3-
require('dotenv').config({
1+
import path from 'path';
2+
import PATHS from '../config/paths';
3+
4+
import { config } from 'dotenv';
5+
config({
46
path: path.join(PATHS.root, '.env')
57
});
68

@@ -10,81 +12,80 @@ const DEPENDENCY_REGEX = BUILD_FOR_IE11
1012
? /node_modules/
1113
: /node_modules\/(@ui5\/webcomponents(-(base|core|fiori|icons|theme-base))?|lit-html)\//;
1214

13-
module.exports = {
14-
stories: ['../docs/**/*.stories.mdx', '../packages/**/*.stories.@(tsx|jsx|mdx)'],
15-
addons: [
16-
'@storybook/addon-toolbars',
17-
'@storybook/addon-docs',
18-
'@storybook/addon-controls',
19-
'@storybook/addon-actions'
20-
],
21-
webpack: async (config, { configType }) => {
22-
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
23-
// You can change the configuration based on that.
24-
// 'PRODUCTION' is used when building the static version of storybook.
15+
export const stories = ['../docs/**/*.stories.mdx', '../packages/**/*.stories.@(tsx|jsx|mdx)'];
2516

26-
config.module.rules.push({
27-
test: /assets\/.*\.json$/,
28-
use: 'file-loader',
29-
type: 'javascript/auto'
30-
});
17+
export const addons = [
18+
'@storybook/addon-toolbars',
19+
'@storybook/addon-docs',
20+
'@storybook/addon-controls',
21+
'@storybook/addon-actions'
22+
];
23+
export async function webpack(config, { configType }) {
24+
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
25+
// You can change the configuration based on that.
26+
// 'PRODUCTION' is used when building the static version of storybook.
3127

32-
if (configType === 'PRODUCTION' || BUILD_FOR_IE11) {
33-
config.module.rules.push({
34-
test: /\.(js|mjs)$/,
35-
include: DEPENDENCY_REGEX,
36-
loader: 'babel-loader',
37-
options: {
38-
sourceType: 'unambiguous',
39-
babelrc: false,
40-
configFile: false,
41-
compact: false,
42-
presets: [
43-
[
44-
'@babel/preset-env',
45-
{
46-
// Allow importing core-js in entrypoint and use browserlist to select polyfills
47-
useBuiltIns: 'entry',
48-
// Set the corejs version we are using to avoid warnings in console
49-
// This will need to change once we upgrade to corejs@3
50-
corejs: 3,
51-
// Do not transform modules to CJS
52-
modules: false,
53-
// Exclude transforms that make all code slower
54-
exclude: ['transform-typeof-symbol']
55-
}
56-
]
57-
],
58-
plugins: [
59-
[
60-
'@babel/plugin-transform-runtime',
61-
{
62-
version: require('@babel/runtime/package.json').version,
63-
useESModules: true
64-
}
65-
]
66-
],
67-
cacheDirectory: true,
68-
cacheCompression: false,
28+
config.module.rules.push({
29+
test: /assets\/.*\.json$/,
30+
use: 'file-loader',
31+
type: 'javascript/auto'
32+
});
6933

70-
// If an error happens in a package, it's possible to be
71-
// because it was compiled. Thus, we don't want the browser
72-
// debugger to show the original code. Instead, the code
73-
// being evaluated would be much more helpful.
74-
sourceMaps: false
75-
}
76-
});
77-
}
78-
config.resolve.alias = {
79-
...config.resolve.alias,
80-
'@shared': path.join(PATHS.root, 'shared'),
81-
'@ui5/webcomponents-react/dist': path.join(PATHS.root, 'packages', 'main', 'dist'),
82-
'@ui5/webcomponents-react': path.join(PATHS.root, 'packages', 'main', 'src'),
83-
'@ui5/webcomponents-react-charts': path.join(PATHS.root, 'packages', 'charts', 'src'),
84-
'@ui5/webcomponents-react-base/types': path.join(PATHS.root, 'packages', 'base', 'types'),
85-
'@ui5/webcomponents-react-base': path.join(PATHS.root, 'packages', 'base', 'src')
86-
};
34+
if (configType === 'PRODUCTION' || BUILD_FOR_IE11) {
35+
config.module.rules.push({
36+
test: /\.(js|mjs)$/,
37+
include: DEPENDENCY_REGEX,
38+
loader: 'babel-loader',
39+
options: {
40+
sourceType: 'unambiguous',
41+
babelrc: false,
42+
configFile: false,
43+
compact: false,
44+
presets: [
45+
[
46+
'@babel/preset-env',
47+
{
48+
// Allow importing core-js in entrypoint and use browserlist to select polyfills
49+
useBuiltIns: 'entry',
50+
// Set the corejs version we are using to avoid warnings in console
51+
// This will need to change once we upgrade to corejs@3
52+
corejs: 3,
53+
// Do not transform modules to CJS
54+
modules: false,
55+
// Exclude transforms that make all code slower
56+
exclude: ['transform-typeof-symbol']
57+
}
58+
]
59+
],
60+
plugins: [
61+
[
62+
'@babel/plugin-transform-runtime',
63+
{
64+
version: require('@babel/runtime/package.json').version,
65+
useESModules: true
66+
}
67+
]
68+
],
69+
cacheDirectory: true,
70+
cacheCompression: false,
8771

88-
return config;
72+
// If an error happens in a package, it's possible to be
73+
// because it was compiled. Thus, we don't want the browser
74+
// debugger to show the original code. Instead, the code
75+
// being evaluated would be much more helpful.
76+
sourceMaps: false
77+
}
78+
});
8979
}
90-
};
80+
config.resolve.alias = {
81+
...config.resolve.alias,
82+
'@shared': path.join(PATHS.root, 'shared'),
83+
'@ui5/webcomponents-react/dist': path.join(PATHS.root, 'packages', 'main', 'dist'),
84+
'@ui5/webcomponents-react': path.join(PATHS.root, 'packages', 'main', 'src'),
85+
'@ui5/webcomponents-react-charts': path.join(PATHS.root, 'packages', 'charts', 'src'),
86+
'@ui5/webcomponents-react-base/types': path.join(PATHS.root, 'packages', 'base', 'types'),
87+
'@ui5/webcomponents-react-base': path.join(PATHS.root, 'packages', 'base', 'src')
88+
};
89+
90+
return config;
91+
}
File renamed without changes.

config/jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const PATHS = require('./paths');
1+
import PATHS from './paths.js';
22

3-
module.exports = {
3+
export default {
44
rootDir: PATHS.root,
55
coverageDirectory: 'coverage',
66
coverageReporters: ['lcov', 'text'],

config/paths.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const path = require('path');
1+
import path from 'path';
22

33
const root = path.resolve(__dirname, '..');
44
const PATHS = {
@@ -13,4 +13,4 @@ const PATHS = {
1313
packages: path.join(root, 'packages')
1414
};
1515

16-
module.exports = PATHS;
16+
export default PATHS;

0 commit comments

Comments
 (0)