Skip to content

Commit

Permalink
Update everything (#63)
Browse files Browse the repository at this point in the history
* upgrade webpack

* fix jest tests

* fix cypress tests

* solve issue with storybook config

* upgrade react to 17

* update yarn lock

* fix circleci cypress

* fix circleci cypress for real

Co-authored-by: Essential Randomness <essential.randomn3ss@gmail.com>
  • Loading branch information
essential-randomness and Essential Randomness authored Jul 21, 2022
1 parent b80b05f commit 6f85b84
Show file tree
Hide file tree
Showing 16 changed files with 3,789 additions and 4,579 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ parameters:
# See: https://circleci.com/docs/2.0/orb-intro/
orbs:
node: circleci/node@4.7
cypress: cypress-io/cypress@1
cypress: cypress-io/cypress@2

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
Expand All @@ -36,5 +36,6 @@ workflows:
pkg-manager: yarn
# See: https://circleci.com/developer/orbs/orb/cypress-io/cypress
- cypress/run:
executor: cypress/base-16-14-2-slim
command: yarn run cypress:ci
yarn: true
37 changes: 15 additions & 22 deletions .storybook/main.cjs
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
const webpackConfig = require("../webpack.config.cjs");

const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
stories: ["../stories/**/*.stories.tsx"],
addons: [
"@storybook/addon-links",
"@storybook/addon-controls",
"@storybook/addon-viewport/register",
"@storybook/addon-actions",
"@storybook/addon-a11y",
"storybook-css-modules-preset",
],
webpackFinal: async (config) => {
addons: ["@storybook/addon-links", "@storybook/addon-controls", "@storybook/addon-viewport/register", "@storybook/addon-actions", "@storybook/addon-a11y", "storybook-css-modules-preset"],
webpackFinal: async config => {
config.devtool = "inline-source-map";
config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [
{
loader: require.resolve("babel-loader"),
options: {
presets: ["@babel/preset-env", "@babel/preset-react"],
},
},
],
use: [{
loader: require.resolve("babel-loader"),
options: {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
}]
});

config.module.rules.push({
test: /\.html$/,
use: ["html-loader"],
use: ["html-loader"]
});

config.resolve.extensions.push(".ts", ".tsx");
return config;
},
features: {
postcss: false,
postcss: false
},
};
core: {
builder: "webpack5"
}
};
18 changes: 18 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from "cypress";

export default defineConfig({
component: {
specPattern: "tests/**/*.spec.{js,ts,jsx,tsx}",
video: false,
screenshotOnRunFailure: false,
chromeWebSecurity: false,
supportFile: "./tests/utils/cypress/commands.js",
devServer: {
framework: "react",
bundler: "webpack",
// optionally pass in webpack config
webpackConfig: require("./tests/utils/cypress/webpack.config.js"),
},
indexHtmlFile: "./tests/utils/cypress/cypress-root.html",
},
});
8 changes: 0 additions & 8 deletions cypress.json

This file was deleted.

5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

25 changes: 0 additions & 25 deletions cypress/plugins/index.js

This file was deleted.

20 changes: 0 additions & 20 deletions cypress/support/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
"\\.(js|ts|tsx)$": "babel-jest",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/tests/utils/file-transformer.js",
"^.+\\.html?$": "html-loader-jest",
"^.+\\.html?$": "<rootDir>/tests/utils/html-transformer.js",
},
moduleNameMapper: {
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
Expand Down
96 changes: 50 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "dist/main.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf dist && tsc -p tsconfig.export.json --emitDeclarationOnly && ./node_modules/.bin/webpack --mode production --config webpack.config.cjs --display-error-details",
"build": "rm -rf dist && tsc -p tsconfig.export.json --emitDeclarationOnly && ./node_modules/.bin/webpack --mode production --config webpack.config.cjs --stats-error-details",
"profile": "tsc -p tsconfig.export.json --emitDeclarationOnly && ./node_modules/.bin/webpack --mode production --config webpack.config.cjs --profile --json > stats.json",
"build:dev": "rm -rf dist && tsc -p tsconfig.export.json --emitDeclarationOnly && ./node_modules/.bin/webpack --mode development --config webpack.config.cjs",
"build:force-dev": "rm -rf dist && ./node_modules/.bin/webpack --mode development",
Expand All @@ -16,8 +16,8 @@
"approve-visuals": "backstop approve",
"test": "jest tests/.*\\.test\\.tsx?",
"test:watch": "yarn run test -- --watch",
"cypress": "cypress open-ct",
"cypress:ci": "cypress run-ct"
"cypress": "cypress open --component",
"cypress:ci": "cypress run --component"
},
"repository": {
"type": "git",
Expand All @@ -37,70 +37,74 @@
"quill": "^1.3.7",
"quill-delta-to-html": "^0.12.0",
"quill-magic-url": "^2.0.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-tenor": "^2.1.1",
"react-tiny-popover": "6.0.5",
"tiny-invariant": "^1.2.0"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
"@babel/preset-env": "^7.14.7",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.16.7",
"@cypress/react": "^5.12.4",
"@cypress/webpack-dev-server": "^1.8.2",
"@storybook/addon-a11y": "6.4.14",
"@storybook/addon-actions": "6.4.14",
"@storybook/addon-controls": "6.4.14",
"@storybook/addon-links": "6.4.14",
"@storybook/addon-viewport": "6.4.14",
"@storybook/addons": "^6.4.14",
"@storybook/react": "6.4.14",
"@storybook/testing-react": "^1.2.3",
"@testing-library/cypress": "^8.0.2",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"@babel/cli": "^7.17.10",
"@babel/core": "^7.18.5",
"@babel/plugin-proposal-class-properties": "^7.17.12",
"@babel/plugin-proposal-optional-chaining": "^7.17.12",
"@babel/preset-env": "^7.18.2",
"@babel/preset-react": "^7.17.12",
"@babel/preset-typescript": "^7.17.12",
"@cypress/react": "^6.0.0",
"@cypress/webpack-dev-server": "^2.0.0",
"@storybook/addon-a11y": "6.5.9",
"@storybook/addon-actions": "6.5.9",
"@storybook/addon-controls": "6.5.9",
"@storybook/addon-links": "6.5.9",
"@storybook/addon-viewport": "6.5.9",
"@storybook/addons": "^6.5.9",
"@storybook/builder-webpack5": "6.5.9",
"@storybook/manager-webpack5": "6.5.9",
"@storybook/react": "6.5.9",
"@storybook/testing-react": "^1.3.0",
"@testing-library/cypress": "^8.0.3",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "12.1.2",
"@testing-library/user-event": "^14.2.1",
"@types/classnames": "^2.2.10",
"@types/dompurify": "^2.2.3",
"@types/jest": "^27.0.3",
"@types/node": "^13.13.4",
"@types/jest": "^28.1.3",
"@types/node": "^18.0.0",
"@types/quill": "1.3.7",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.7",
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.2",
"@types/uuid": "^8.3.0",
"babel-loader": "^8.1.0",
"babel-loader": "^8.2.5",
"base64-image-loader": "^1.2.1",
"cross-env": "^7.0.2",
"css-loader": "5.2.7",
"cypress": "^9.5.1",
"css-loader": "6.7.1",
"cypress": "^10.2.0",
"cypress-wait-until": "^1.7.2",
"eslint-plugin-jsx-a11y": "^6.5.1",
"file-loader": "^6.2.0",
"html-loader": "1.3.2",
"html-loader-jest": "^0.2.1",
"html-loader": "3.1.2",
"html-webpack-plugin": "^5.5.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.2.5",
"mini-css-extract-plugin": "^0.9.0",
"jest": "^28.1.1",
"jest-environment-jsdom": "^28.1.1",
"mini-css-extract-plugin": "^2.6.1",
"storybook-css-modules-preset": "^1.1.1",
"style-loader": "2",
"ts-jest": "^25.4.0",
"typescript": "^4.3.5",
"style-loader": "3.3.1",
"ts-jest": "^28.0.5",
"typescript": "^4.7.4",
"typescript-plugin-css-modules": "^3.4.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^4.6.0"
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.9.2"
},
"peerDependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1"
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"resolutions": {
"**/@types/react": "^16.13.1"
"**/@types/react": "^17.0.2",
"@storybook/react/webpack": "^5"
},
"keywords": [
"editor",
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions tests/utils/cypress/cypress-root.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Cypress tests</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const ogWebpack = require("../../webpack.config.cjs");
const ogWebpack = require("../../../webpack.config.cjs");

module.exports = {
// Currently we need to add '.ts' to the resolve.extensions array.
Expand Down
4 changes: 3 additions & 1 deletion tests/utils/file-transformer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require("path");
module.exports = {
process(_, filename) {
return "module.exports = " + JSON.stringify(path.basename(filename)) + ";";
return {
code: "module.exports = " + JSON.stringify(path.basename(filename)) + ";",
};
},
};
7 changes: 7 additions & 0 deletions tests/utils/html-transformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
process(source) {
return {
code: `module.exports = ${JSON.stringify(source)};`,
};
},
};
10 changes: 7 additions & 3 deletions webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ module.exports = {
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
},
plugins: [new MiniCssExtractPlugin()],
target: "node",
plugins: [
new MiniCssExtractPlugin({
experimentalUseImportModule: false,
}),
],
target: "web",
output: {
path: path.join(__dirname, "dist"),
filename: "[name].js",
library: "boba-editor",
libraryTarget: "umd",
globalObject: "globalThis",
globalObject: "this",
},
entry: {
main: path.join(__dirname, "src/", "index.ts"),
Expand Down
Loading

0 comments on commit 6f85b84

Please sign in to comment.