Skip to content

Commit

Permalink
🔧 Enable ES module interop
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent John Cagay committed Aug 22, 2020
1 parent 51aa55c commit c8f335c
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
dist/
node_modules/
dev/
Expand Down
8 changes: 2 additions & 6 deletions src/ts/Message.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import * as React from "react";
import React from "react";
import styled from "styled-components";

const MessageStyled = styled.div`
text-transform: uppercase;
`;

const MessageComponent = () => (
<MessageStyled>
Hello World of TypeScript!
</MessageStyled>
);
const MessageComponent = () => <MessageStyled>Hello World of TypeScript!</MessageStyled>;

export default MessageComponent;
2 changes: 1 addition & 1 deletion src/ts/__tests__/Message.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "react";
import React from "react";
import "@testing-library/jest-dom";
import { render } from "@testing-library/react";
import Message from "../Message";
Expand Down
8 changes: 4 additions & 4 deletions src/ts/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import * as ReactDOM from "react-dom";
import React from "react";
import ReactDOM from "react-dom";
import { createGlobalStyle } from "styled-components";
import { reset } from "styled-reset";

Expand All @@ -22,13 +22,13 @@ const GlobalStyle = createGlobalStyle`
font-size: 2em;
text-align: center;
}
`
`;

const App = () => (
<>
<GlobalStyle />
<Message />
</>
)
);

ReactDOM.render(<App />, document.getElementById("app"));
20 changes: 5 additions & 15 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@
"compilerOptions": {
"noImplicitAny": true,
"module": "commonjs",
"esModuleInterop": true,
"jsx": "react",
"sourceMap": true,
"target": "es5",
"types": [
"node",
"jest"
],
"baseUrl": ".",
"types": ["node", "jest"],
"baseUrl": "."
},
"exclude": [
"node_modules",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"webpack.config.ts"
]
"exclude": ["node_modules", "src/**/*.spec.ts", "src/**/*.spec.tsx"],
"include": ["src/**/*.ts", "src/**/*.tsx", "webpack.config.ts"]
}
15 changes: 9 additions & 6 deletions webpack.config.dll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { Configuration } from "webpack";
import devDLLConfig from "./webpack/development.dll";
import prodDLLConfig from "./webpack/production.dll";

const config = (_: any, args: Configuration): Configuration => { /* eslint-disable-line */
const config = (_: any, args: Configuration): Configuration => {
/* eslint-disable-line */
/**
* The common WebPack configuration no matter what environment it is run on
*/
Expand All @@ -23,11 +24,13 @@ const config = (_: any, args: Configuration): Configuration => { /* eslint-disab
},
mode: args.mode,
module: {
rules: [{
exclude: /node_modules/,
test: /\.ts?$/,
use: "ts-loader",
}],
rules: [
{
exclude: /node_modules/,
test: /\.ts?$/,
use: "ts-loader",
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".sass", ".css"],
Expand Down
4 changes: 2 additions & 2 deletions webpack/development.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as HTMLWebpackPlugin from "html-webpack-plugin";
import * as HTMLWebpackTagsPlugin from "html-webpack-tags-plugin";
import HTMLWebpackPlugin from "html-webpack-plugin";
import HTMLWebpackTagsPlugin from "html-webpack-tags-plugin";
import { join, resolve } from "path";
import {
Configuration,
Expand Down
2 changes: 1 addition & 1 deletion webpack/production.dll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CleanWebpackPlugin } from "clean-webpack-plugin";
import * as CompressionWebpackPlugin from "compression-webpack-plugin";
import CompressionWebpackPlugin from "compression-webpack-plugin";
import { join } from "path";
import { Configuration, DllPlugin } from "webpack";

Expand Down
6 changes: 3 additions & 3 deletions webpack/production.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CleanWebpackPlugin } from "clean-webpack-plugin";
import * as CompressionWebpackPlugin from "compression-webpack-plugin";
import * as HTMLWebpackPlugin from "html-webpack-plugin";
import * as HTMLWebpackTagsPlugin from "html-webpack-tags-plugin";
import CompressionWebpackPlugin from "compression-webpack-plugin";
import HTMLWebpackPlugin from "html-webpack-plugin";
import HTMLWebpackTagsPlugin from "html-webpack-tags-plugin";
import { join, resolve } from "path";
import { Configuration, DllReferencePlugin } from "webpack";

Expand Down

0 comments on commit c8f335c

Please sign in to comment.