Skip to content

Commit

Permalink
fix: drop project type module
Browse files Browse the repository at this point in the history
  • Loading branch information
knilink committed Oct 19, 2022
1 parent 2c88708 commit 90828a1
Show file tree
Hide file tree
Showing 23 changed files with 107 additions and 133 deletions.
2 changes: 1 addition & 1 deletion babel.config.cjs → babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const svgoConfig = require('./svgo-config.cjs');
const svgoConfig = require('./svgo-config.js');

const isDevelopment = process.env.TYPE === 'development';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import webpack from 'webpack';
import { merge as webpackMerge } from 'webpack-merge';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import * as commonConfig from './webpack.config.js';
import { default as paths } from './paths.js';
import * as commonConfig from './webpack.config.mjs';
import { default as paths } from './paths.mjs';

// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
Expand Down Expand Up @@ -62,12 +62,6 @@ export default webpackMerge(commonConfig.default, {
options: {
cacheDirectory: true,
},
resolve: {
// https://webpack.js.org/configuration/module/#resolvefullyspecified
// temp fix for migrating to esm
// needs to be reviewed and discussed later
fullySpecified: false,
},
},
{
test: /\.css$/i,
Expand Down
10 changes: 2 additions & 8 deletions config/webpack.config.dev.js → config/webpack.config.dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import webpack from 'webpack';
import { merge as webpackMerge } from 'webpack-merge';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
import * as commonConfig from './webpack.config.js';
import { default as paths } from './paths.js';
import * as commonConfig from './webpack.config.mjs';
import { default as paths } from './paths.mjs';

// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
Expand Down Expand Up @@ -52,12 +52,6 @@ export default webpackMerge(commonConfig.default, {
},
},
],
resolve: {
// https://webpack.js.org/configuration/module/#resolvefullyspecified
// temp fix for migrating to esm
// needs to be reviewed and discussed later
fullySpecified: false,
},
},
{
test: /\.(eot|ttf|woff|woff2)$/,
Expand Down
10 changes: 2 additions & 8 deletions config/webpack.config.dist.js → config/webpack.config.dist.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { merge as webpackMerge } from 'webpack-merge';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
import * as commonConfig from './webpack.config.js';
import { default as paths } from './paths.js';
import * as commonConfig from './webpack.config.mjs';
import { default as paths } from './paths.mjs';

// Assert this just to be safe.
if (process.env.NODE_ENV !== 'dist') {
Expand Down Expand Up @@ -83,12 +83,6 @@ export default webpackMerge(commonConfig.default, {
options: {
cacheDirectory: true,
},
resolve: {
// https://webpack.js.org/configuration/module/#resolvefullyspecified
// temp fix for migrating to esm
// needs to be reviewed and discussed later
fullySpecified: false,
},
},
{
test: /\.css$/i,
Expand Down
2 changes: 1 addition & 1 deletion config/webpack.config.js → config/webpack.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { default as paths } from './paths.js';
import { default as paths } from './paths.mjs';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const buffer = require.resolve('buffer/');
Expand Down
10 changes: 2 additions & 8 deletions config/webpack.config.prod.js → config/webpack.config.prod.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
import * as commonConfig from './webpack.config.js';
import { default as paths } from './paths.js';
import * as commonConfig from './webpack.config.mjs';
import { default as paths } from './paths.mjs';

// Assert this just to be safe.
if (process.env.NODE_ENV !== 'production') {
Expand Down Expand Up @@ -86,12 +86,6 @@ export default webpackMerge(commonConfig.default, {
test: /\.(js|jsx)$/,
include: [paths.appSrc, paths.appDemo],
loader: 'babel-loader',
resolve: {
// https://webpack.js.org/configuration/module/#resolvefullyspecified
// temp fix for migrating to esm
// needs to be reviewed and discussed later
fullySpecified: false,
},
},
{
test: /\.css$/i,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { default as config } from './webpack.config.dev.js';
import { default as paths } from './paths.js';
import { default as config } from './webpack.config.dev.mjs';
import { default as paths } from './paths.mjs';

const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
const host = process.env.HOST || '0.0.0.0';
Expand Down
2 changes: 1 addition & 1 deletion jest.config.cjs → jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
moduleFileExtensions: ['js', 'jsx', 'json'],
transform: {
'^.+\\.(js|jsx)?$': 'babel-jest',
'^.+\\.css$': '<rootDir>/config/cssTransform.js',
'^.+\\.css$': '<rootDir>/config/cssTransform.mjs',
},
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$'],
clearMocks: true,
Expand Down
25 changes: 12 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"main": "lib/index.js",
"module": "es/index.js",
"types": "es/index.d.ts",
"type": "module",
"files": [
"dist",
"src/styles",
Expand All @@ -14,30 +13,30 @@
],
"license": "MIT",
"scripts": {
"generate-docs": "node ./scripts/generateDocs.js",
"generate-docs": "node ./scripts/generateDocs.mjs",
"clean": "rimraf dist/* docs/* lib/* es/*",
"generate-types": "node ./scripts/generate-types/generateTypes.js",
"generate-types": "node ./scripts/generate-types/generateTypes.mjs",
"copy-types": "npm run generate-types -- -c",
"type-check": "npx -p typescript tsc --allowSyntheticDefaultImports",
"deps": "ADBLOCK=true DISABLE_OPENCOLLECTIVE=true npm ci",
"dist:prod": "cross-env NODE_ENV=dist node ./scripts/build.js",
"dist:lib": "cross-env NODE_ENV=cjs node ./scripts/babel-build.js",
"dist:es": "cross-env NODE_ENV=esm node ./scripts/babel-build.js",
"dist:demo": "cross-env NODE_ENV=production DEMO_ASSETS=true node ./scripts/build.js",
"dist:prod": "cross-env NODE_ENV=dist node ./scripts/build.mjs",
"dist:lib": "cross-env NODE_ENV=cjs node ./scripts/babel-build.mjs",
"dist:es": "cross-env NODE_ENV=esm node ./scripts/babel-build.mjs",
"dist:demo": "cross-env NODE_ENV=production DEMO_ASSETS=true node ./scripts/build.mjs",
"dist": "npm run clean && npm run copy-types && npm run dist:lib && npm run dist:es && npm run dist:prod && npm run generate-docs && npm run dist:demo",
"lint:eslint": "eslint --ext .jsx,.js,.ts ./src && eslint --ext .jsx,.js ./www",
"lint:eslint": "eslint --ext .jsx,.js,cjs,mjs,.ts ./src && eslint --ext .jsx,.js ./www",
"lint:stylelint": "stylelint '{src,www}/**/*.css'",
"lint:prettier": "prettier '{src,www,config}/**/*.{js,json,jsx,md,mdx,css}' --check",
"format": "prettier '{src,www,config}/**/*.{js,json,jsx,md,mdx,css}' --write",
"lint:prettier": "prettier '{src,www,config}/**/*.{js,json,jsx,cjs,mjs,md,mdx,css}' --check",
"format": "prettier '{src,www,config}/**/*.{js,json,jsx,cjs,mjs,md,mdx,css}' --write",
"lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:stylelint",
"prettier": "prettier \"{src,www,config}/**/*.{js,json,jsx,md,mdx,css}\" --write",
"svgo": "svgo --recursive --multipass --folder=src --config=svgo-config.cjs",
"prettier": "prettier \"{src,www,config}/**/*.{js,json,jsx,cjs,mjs,md,mdx,css}\" --write",
"svgo": "svgo --recursive --multipass --folder=src --config=svgo-config.js",
"postversion": "git push -u origin $(git rev-parse --abbrev-ref HEAD) --follow-tags && npm publish && echo '…released.'",
"preversion": "echo 'Releasing…' && ADBLOCK=true DISABLE_OPENCOLLECTIVE=true npm ci",
"release:major": "npm version major -m 'build: release major version %s'",
"release:minor": "npm version minor -m 'build: release minor version %s'",
"release:patch": "npm version patch -m 'build: release patch version %s'",
"start": "npm run generate-docs && node scripts/start.js",
"start": "npm run generate-docs && node scripts/start.mjs",
"test": "jest --watch",
"coverage": "jest --colors --coverage",
"version": "echo '…generating dist…' && npm run dist",
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions scripts/build.js → scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import fs from 'fs';
import path from 'path';
import webpack from 'webpack';

import paths from '../config/paths.js';
import paths from '../config/paths.mjs';
import checkRequiredFiles from 'react-dev-utils/checkRequiredFiles.js';
import formatWebpackMessages from 'react-dev-utils/formatWebpackMessages.js';
import FileSizeReporter from 'react-dev-utils/FileSizeReporter.js';
import printBuildError from 'react-dev-utils/printBuildError.js';

let configFile = '../config/webpack.config.dev.build.js';
let configFile = '../config/webpack.config.dev.build.mjs';
if (process.env.NODE_ENV === 'dist') {
configFile = '../config/webpack.config.dist.js';
configFile = '../config/webpack.config.dist.mjs';
}
if (process.env.NODE_ENV === 'production') {
configFile = '../config/webpack.config.prod.js';
configFile = '../config/webpack.config.prod.mjs';
}
const config = (await import(configFile)).default;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs/promises';
import globPkg from 'glob';
import chalk from 'chalk';
import paths from '../../config/paths.js';
import paths from '../../config/paths.mjs';

const { glob } = globPkg;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import chalk from 'chalk';
import fs from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import paths from '../../config/paths.js';
import parsePropTypesVariables from './babel-plugin-proptype-vars.js';
import copyTypes from './copyTypes.js';
import typesPostFixes from './typesPostFixes.js';
import paths from '../../config/paths.mjs';
import parsePropTypesVariables from './babel-plugin-proptype-vars.mjs';
import copyTypes from './copyTypes.mjs';
import typesPostFixes from './typesPostFixes.mjs';

const { glob } = globPkg;

Expand Down Expand Up @@ -128,7 +128,6 @@ async function generateTypeDefs() {
console.log(chalk.green.bold(`Generated type defs for ${component.componentName}`));

const output = typesPostFixes(component.componentName, result);
// const pkg = await import('../../package.json', { assert: { type: 'json' } });
const pkg = JSON.parse(await fs.readFile(path.resolve(__dirname, '../../package.json')));
const prettifiedOutput = prettier.format(output, { parser: 'typescript', ...pkg.prettier });

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions scripts/start.js → scripts/start.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import clearConsole from 'react-dev-utils/clearConsole.js';
import checkRequiredFiles from 'react-dev-utils/checkRequiredFiles.js';
import { choosePort, createCompiler, prepareProxy, prepareUrls } from 'react-dev-utils/WebpackDevServerUtils.js';
import openBrowser from 'react-dev-utils/openBrowser.js';
import paths from '../config/paths.js';
import config from '../config/webpack.config.dev.js';
import createDevServerConfig from '../config/webpackDevServer.config.js';
import paths from '../config/paths.mjs';
import config from '../config/webpack.config.dev.mjs';
import createDevServerConfig from '../config/webpackDevServer.config.mjs';

process.env.NODE_ENV = 'development';

Expand Down
140 changes: 70 additions & 70 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,76 @@ import './styles/bootstrap-custom.css';

import { registerLocale } from 'react-datepicker';

import Accordion from './components/Accordion/index.jsx';
import ActionPanel from './components/ActionPanel/index.jsx';
import Alert from './components/Alert/index.jsx';
import AlertInput from './components/AlertInput/index.jsx';
import Anchor from './components/Anchor/index.jsx';
import Avatar from './components/Avatar/index.jsx';
import BorderedWell from './components/BorderedWell/index.jsx';
import Breadcrumb from './components/Breadcrumb/index.jsx';
import Button from './components/Button/index.jsx';
import ButtonGroup from './components/ButtonGroup/index.jsx';
import Card from './components/Card/index.jsx';
import Carousel from './components/Carousel/index.jsx';
import Checkbox from './components/Checkbox/index.jsx';
import CheckboxGroup from './components/CheckboxGroup/index.jsx';
import ConfirmModal from './components/ConfirmModal/index.jsx';
import CountBadge from './components/CountBadge/index.jsx';
import DatePicker from './components/DatePicker/index.jsx';
import Empty from './components/Empty/index.jsx';
import fastStatelessWrapper from './components/fastStatelessWrapper/index.jsx';
import FilePicker from './components/FilePicker/index.jsx';
import FlexibleSpacer from './components/FlexibleSpacer/index.jsx';
import FormGroup from './components/FormGroup/index.jsx';
import Grid from './components/Grid/index.jsx';
import GridCell from './components/Grid/Cell/index.jsx';
import GridRow from './components/Grid/Row/index.jsx';
import HelpIconPopover from './components/HelpIconPopover/index.jsx';
import HoverDropdownMenu from './components/HoverDropdownMenu/index.jsx';
import ImageCropper from './components/ImageCropper/index.jsx';
import InformationBox from './components/InformationBox/index.jsx';
import ListPicker from './components/ListPicker/index.jsx';
import ListPickerPure from './components/ListPickerPure/index.jsx';
import Nav, { NavItem } from './components/Navigation/index.jsx';
import OverlayLoader from './components/OverlayLoader/index.jsx';
import PagedGrid from './components/PagedGrid/index.jsx';
import PageTitle from './components/PageTitle/index.jsx';
import Pagination from './components/Pagination/index.jsx';
import Panel from './components/Panel/index.jsx';
import Paragraph from './components/Paragraph/index.jsx';
import Pill from './components/Pill/index.jsx';
import Popover from './components/Popover/index.jsx';
import PrettyDiff from './components/PrettyDiff/index.jsx';
import Radio from './components/Radio/index.jsx';
import RadioGroup from './components/RadioGroup/index.jsx';
import RichTextEditor from './components/RichTextEditor/index.jsx';
import Search from './components/Search/index.jsx';
import SearchableCheckList from './components/SearchableCheckList/index.jsx';
import Select from './components/Select/index.jsx';
import Skeleton from './components/Skeleton/index.jsx';
import Slicey from './components/Slicey/index.jsx';
import Spinner from './components/Spinner/index.jsx';
import SplitPane from './components/SplitPane/index.jsx';
import Statistic from './components/Statistic/index.jsx';
import StatusPill from './components/StatusPill/index.jsx';
import SvgSymbol from './components/SvgSymbol/index.jsx';
import Switch from './components/Switch/index.jsx';
import Tab from './components/Tab/index.jsx';
import Tabs from './components/Tabs/index.jsx';
import Tag from './components/Tag/index.jsx';
import Textarea from './components/Textarea/index.jsx';
import TextEllipsis from './components/TextEllipsis/index.jsx';
import Tile from './components/Tile/index.jsx';
import TileGrid from './components/TileGrid/index.jsx';
import Toast from './components/Toast/index.jsx';
import Totals from './components/Totals/index.jsx';
import TreePickerSimplePure from './components/TreePicker/index.jsx';
import TreePickerGrid from './components/TreePicker/Grid/index.jsx';
import TreePickerNav from './components/TreePicker/Nav/index.jsx';
import TreePickerNode from './components/TreePicker/Node/index.jsx';
import UserListPicker from './components/UserListPicker/index.jsx';
import VerticalNav from './components/VerticalNavigation/index.jsx';
import Accordion from './components/Accordion';
import ActionPanel from './components/ActionPanel';
import Alert from './components/Alert';
import AlertInput from './components/AlertInput';
import Anchor from './components/Anchor';
import Avatar from './components/Avatar';
import BorderedWell from './components/BorderedWell';
import Breadcrumb from './components/Breadcrumb';
import Button from './components/Button';
import ButtonGroup from './components/ButtonGroup';
import Card from './components/Card';
import Carousel from './components/Carousel';
import Checkbox from './components/Checkbox';
import CheckboxGroup from './components/CheckboxGroup';
import ConfirmModal from './components/ConfirmModal';
import CountBadge from './components/CountBadge';
import DatePicker from './components/DatePicker';
import Empty from './components/Empty';
import fastStatelessWrapper from './components/fastStatelessWrapper';
import FilePicker from './components/FilePicker';
import FlexibleSpacer from './components/FlexibleSpacer';
import FormGroup from './components/FormGroup';
import Grid from './components/Grid';
import GridCell from './components/Grid/Cell';
import GridRow from './components/Grid/Row';
import HelpIconPopover from './components/HelpIconPopover';
import HoverDropdownMenu from './components/HoverDropdownMenu';
import ImageCropper from './components/ImageCropper';
import InformationBox from './components/InformationBox';
import ListPicker from './components/ListPicker';
import ListPickerPure from './components/ListPickerPure';
import Nav, { NavItem } from './components/Navigation';
import OverlayLoader from './components/OverlayLoader';
import PagedGrid from './components/PagedGrid';
import PageTitle from './components/PageTitle';
import Pagination from './components/Pagination';
import Panel from './components/Panel';
import Paragraph from './components/Paragraph';
import Pill from './components/Pill';
import Popover from './components/Popover';
import PrettyDiff from './components/PrettyDiff';
import Radio from './components/Radio';
import RadioGroup from './components/RadioGroup';
import RichTextEditor from './components/RichTextEditor';
import Search from './components/Search';
import SearchableCheckList from './components/SearchableCheckList';
import Select from './components/Select';
import Skeleton from './components/Skeleton';
import Slicey from './components/Slicey';
import Spinner from './components/Spinner';
import SplitPane from './components/SplitPane';
import Statistic from './components/Statistic';
import StatusPill from './components/StatusPill';
import SvgSymbol from './components/SvgSymbol';
import Switch from './components/Switch';
import Tab from './components/Tab';
import Tabs from './components/Tabs';
import Tag from './components/Tag';
import Textarea from './components/Textarea';
import TextEllipsis from './components/TextEllipsis';
import Tile from './components/Tile';
import TileGrid from './components/TileGrid';
import Toast from './components/Toast';
import Totals from './components/Totals';
import TreePickerSimplePure from './components/TreePicker';
import TreePickerGrid from './components/TreePicker/Grid';
import TreePickerNav from './components/TreePicker/Nav';
import TreePickerNode from './components/TreePicker/Node';
import UserListPicker from './components/UserListPicker';
import VerticalNav from './components/VerticalNavigation';

export {
Accordion,
Expand Down
File renamed without changes.

0 comments on commit 90828a1

Please sign in to comment.