chore: Jest setup wip.

This commit is contained in:
Gervwyk 2021-11-09 14:51:20 +02:00
parent cf176d71f4
commit 88953d4eae
26 changed files with 80 additions and 794 deletions

3
.swcrc
View File

@ -7,7 +7,8 @@
"dynamicImport": true
},
"target": "es2020",
"keepClassNames": true
"keepClassNames": true,
"transform": { "react": { "runtime": "automatic" } }
},
"module": {
"type": "es6",

View File

@ -6,7 +6,8 @@
"dynamicImport": true
},
"target": "es2020",
"keepClassNames": true
"keepClassNames": true,
"transform": { "react": { "runtime": "automatic" } }
},
"module": {
"type": "es6",

View File

@ -1,14 +1,3 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "12",
"esmodules": true
}
}
],
"@babel/preset-react"
]
"presets": ["@babel/preset-react"]
}

View File

@ -0,0 +1,22 @@
module.exports = {
clearMocks: true,
collectCoverage: true,
collectCoverageFrom: ['src/**/*.{js,jsx}', '!demo/*'],
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: [
'runRenderTests.js',
'runMockRenderTests.js',
'runMockMethodTests.js',
'runBlockSchemaTests.js',
'mockBlock.js',
],
coverageReporters: [['lcov', { projectRoot: '../..' }], 'text', 'clover'],
errorOnDeprecated: true,
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['<rootDir>/dist/'],
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node', 'yaml', 'css'],
transform: {
'\\.js?$': 'babel-jest',
},
snapshotSerializers: ['@emotion/jest/serializer', 'jest-serializer-html'],
};

View File

@ -1,15 +0,0 @@
module.exports = {
clearMocks: true,
collectCoverage: false,
errorOnDeprecated: true,
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['<rootDir>/dist/'],
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node', 'yaml', 'css'],
moduleNameMapper: {
'\\.(css|less)$': '<rootDir>/tests/__mocks__/styleMock.js',
},
transform: {
'\\.js?$': 'babel-jest',
'\\.yaml$': 'jest-transform-yaml',
},
};

View File

@ -25,14 +25,17 @@
"type": "git",
"url": "https://github.com/lowdefy/lowdefy.git"
},
"main": "dist/index.js",
"type": "module",
"exports": "./dist/index.js",
"files": [
"dist/*"
],
"scripts": {
"build": "babel src --copy-files --out-dir dist",
"build": "yarn swc",
"clean": "rm -rf dist",
"prepare": "yarn build",
"swc": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start",
"test:watch": "jest --coverage --watch",
"test": "jest --coverage"
},
"dependencies": {
@ -46,17 +49,16 @@
"ajv-errors": "3.0.0",
"jest": "27.3.1",
"jest-serializer-html": "7.1.0",
"jest-transform-yaml": "0.1.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-router": "5.2.1",
"yaml-loader": "0.6.0"
},
"devDependencies": {
"@babel/cli": "7.15.7",
"@babel/core": "7.15.8",
"@babel/preset-env": "7.15.8",
"@babel/preset-react": "7.14.5",
"@babel/core": "7.16.0",
"@babel/preset-react": "7.16.0",
"@swc/cli": "0.1.51",
"@swc/core": "1.2.107",
"@swc/jest": "0.2.5",
"babel-jest": "27.3.1"
},
"publishConfig": {

View File

@ -1,3 +1,19 @@
/*
Copyright 2020-2021 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from 'react';
const BlockSchemaErrors = ({ schemaErrors }) => {

View File

@ -14,13 +14,13 @@
limitations under the License.
*/
import BlockSchemaErrors from './BlockSchemaErrors';
import mockBlock from './mockBlock';
import runBlockSchemaTests from './runBlockSchemaTests';
import runMockMethodTests from './runMockMethodTests';
import runMockRenderTests from './runMockRenderTests';
import runRenderTests from './runRenderTests';
import stubBlockProps from './stubBlockProps';
import BlockSchemaErrors from './BlockSchemaErrors.js';
import mockBlock from './mockBlock.js';
import runBlockSchemaTests from './runBlockSchemaTests.js';
import runMockMethodTests from './runMockMethodTests.js';
import runMockRenderTests from './runMockRenderTests.js';
import runRenderTests from './runRenderTests.js';
import stubBlockProps from './stubBlockProps.js';
export {
BlockSchemaErrors,

View File

@ -16,7 +16,7 @@
import { makeCssClass } from '@lowdefy/block-tools';
import stubBlockProps from './stubBlockProps';
import stubBlockProps from './stubBlockProps.js';
const mockBlock = ({ meta, logger }) => {
const mockMath = Object.create(global.Math);

View File

@ -14,7 +14,7 @@
limitations under the License.
*/
import schemaTest from './schemaTest';
import schemaTest from './schemaTest.js';
const runBlockSchemaTests = ({ examples, meta }) => {
const validate = schemaTest(meta.schema);

View File

@ -19,7 +19,7 @@ import { type } from '@lowdefy/helpers';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import mockBlock from './mockBlock';
import mockBlock from './mockBlock.js';
const runMockMethodTests = ({ Block, examples, logger, meta, mocks }) => {
const { before, methods, getProps } = mockBlock({ meta, logger });

View File

@ -16,10 +16,9 @@
import React from 'react';
import { type } from '@lowdefy/helpers';
import { MemoryRouter } from 'react-router';
import { render } from '@testing-library/react';
import mockBlock from './mockBlock';
import mockBlock from './mockBlock.js';
const runMockRenderTests = ({ Block, examples, logger, meta, mocks, reset = () => null }) => {
const { before, getProps } = mockBlock({ meta, logger });
@ -45,11 +44,7 @@ const runMockRenderTests = ({ Block, examples, logger, meta, mocks, reset = () =
const props = getProps(ex);
return <Block {...props} methods={{ ...props.methods, makeCssClass }} value={value} />;
};
render(
<MemoryRouter>
<Shell />
</MemoryRouter>
);
render(<Shell />);
expect(mock.fn.mock.calls).toMatchSnapshot();
});
});

View File

@ -17,9 +17,8 @@
import React from 'react';
import { render, waitFor } from '@testing-library/react';
import { type } from '@lowdefy/helpers';
import { MemoryRouter } from 'react-router';
import mockBlock from './mockBlock';
import mockBlock from './mockBlock.js';
const runRenderTests = ({
Block,
@ -48,11 +47,7 @@ const runRenderTests = ({
test(`Render ${ex.id} - value[${v}]`, async () => {
// create shell to setup react hooks with getProps before render;
const Shell = () => <Block {...getProps(ex)} value={value} methods={methods} />;
const { container } = render(
<MemoryRouter>
<Shell />
</MemoryRouter>
);
const { container } = render(<Shell />);
await waitFor(() => expect(container.firstChild).toMatchSnapshot());
});
@ -63,11 +58,7 @@ const runRenderTests = ({
const Shell = () => (
<Block {...getProps(ex)} value={value} methods={methods} validation={validationEx} />
);
const { container } = render(
<MemoryRouter>
<Shell />
</MemoryRouter>
);
const { container } = render(<Shell />);
await waitFor(() => expect(container.firstChild).toMatchSnapshot());
});
});
@ -77,11 +68,7 @@ const runRenderTests = ({
test(`Render required = true ${ex.id} - value[${v}]`, async () => {
// create shell to setup react hooks with getProps before render;
const Shell = () => <Block {...getProps(ex)} value={value} methods={methods} required />;
const { container } = render(
<MemoryRouter>
<Shell />
</MemoryRouter>
);
const { container } = render(<Shell />);
await waitFor(() => expect(container.firstChild).toMatchSnapshot());
});
}

View File

@ -1,4 +1,4 @@
import schemaTest from './schemaTest';
import schemaTest from './schemaTest.js';
test(`Test Schema pass`, () => {
const validate = schemaTest({
@ -44,17 +44,7 @@ test(`Test Schema fail required`, () => {
},
});
expect(valid).toEqual(false);
expect(validate.errors).toEqual([
{
dataPath: '',
keyword: 'required',
message: "should have required property 'id'",
params: {
missingProperty: 'id',
},
schemaPath: '#/required',
},
]);
expect(validate.errors).toMatchSnapshot();
});
test(`Test Schema fail properties`, () => {
@ -78,15 +68,5 @@ test(`Test Schema fail properties`, () => {
},
});
expect(valid).toEqual(false);
expect(validate.errors).toEqual([
{
dataPath: '/properties',
keyword: 'additionalProperties',
message: 'should NOT have additional properties',
params: {
additionalProperty: 'mistake',
},
schemaPath: '#/properties/properties/additionalProperties',
},
]);
expect(validate.errors).toMatchSnapshot();
});

View File

@ -18,7 +18,7 @@ import React, { useState } from 'react';
import { type } from '@lowdefy/helpers';
import { makeCssClass } from '@lowdefy/block-tools';
import schemaTest from './schemaTest';
import schemaTest from './schemaTest.js';
const validate = {};

View File

@ -1 +0,0 @@
module.exports = {};

View File

@ -1,16 +1,15 @@
module.exports = {
clearMocks: true,
collectCoverage: true,
collectCoverageFrom: ['src/**/*.{js,jsx}'],
collectCoverageFrom: ['src/**/*.{js,jsx}', '!demo/*'],
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/test/', '<rootDir>/src/index.js'],
coverageReporters: [['lcov', { projectRoot: '../..' }], 'text', 'clover'],
errorOnDeprecated: true,
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['<rootDir>/dist/'],
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node', 'yaml', 'css'],
transform: {
'^.+\\.(t|j)sx?$': ['@swc/jest', { configFile: '../../.swcrc.test' }],
'\\.js?$': 'babel-jest',
},
snapshotSerializers: ['@emotion/jest/serializer', 'jest-serializer-html'],
};

View File

@ -36,7 +36,7 @@
"prepare": "yarn build",
"swc": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start",
"test:watch": "jest --coverage --watch",
"test": "jest --coverage"
"test": "jest --coverage --experimental-modules"
},
"dependencies": {
"@emotion/css": "11.5.0",
@ -48,14 +48,17 @@
"react-dom": "17.0.2"
},
"devDependencies": {
"@babel/core": "7.16.0",
"@babel/preset-env": "7.16.0",
"@babel/preset-react": "7.16.0",
"@emotion/jest": "11.5.0",
"@lowdefy/block-dev": "3.22.0",
"@swc/cli": "0.1.51",
"@swc/core": "1.2.107",
"@swc/jest": "0.2.5",
"@testing-library/dom": "8.10.1",
"@testing-library/react": "12.1.2",
"@testing-library/user-event": "13.5.0",
"babel-jest": "27.3.1",
"jest": "27.3.1",
"jest-serializer-html": "7.1.0"
},

View File

@ -1,496 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [3.22.0](https://github.com/lowdefy/lowdefy/compare/v3.22.0-alpha.1...v3.22.0) (2021-09-27)
**Note:** Version bump only for package @lowdefy/format
# [3.22.0-alpha.1](https://github.com/lowdefy/lowdefy/compare/v3.22.0-alpha.0...v3.22.0-alpha.1) (2021-09-20)
**Note:** Version bump only for package @lowdefy/format
# [3.22.0-alpha.0](https://github.com/lowdefy/lowdefy/compare/v3.21.2...v3.22.0-alpha.0) (2021-09-08)
**Note:** Version bump only for package @lowdefy/format
## [3.21.2](https://github.com/lowdefy/lowdefy/compare/v3.21.2-alpha.0...v3.21.2) (2021-08-31)
**Note:** Version bump only for package @lowdefy/format
## [3.21.2-alpha.0](https://github.com/lowdefy/lowdefy/compare/v3.21.1...v3.21.2-alpha.0) (2021-08-31)
**Note:** Version bump only for package @lowdefy/format
## [3.21.1](https://github.com/lowdefy/lowdefy/compare/v3.21.0...v3.21.1) (2021-08-26)
**Note:** Version bump only for package @lowdefy/format
# [3.21.0](https://github.com/lowdefy/lowdefy/compare/v3.20.4...v3.21.0) (2021-08-25)
**Note:** Version bump only for package @lowdefy/format
## [3.20.4](https://github.com/lowdefy/lowdefy/compare/v3.20.3...v3.20.4) (2021-08-21)
**Note:** Version bump only for package @lowdefy/format
## [3.20.3](https://github.com/lowdefy/lowdefy/compare/v3.20.1...v3.20.3) (2021-08-20)
**Note:** Version bump only for package @lowdefy/format
## [3.20.2](https://github.com/lowdefy/lowdefy/compare/v3.20.1...v3.20.2) (2021-08-20)
**Note:** Version bump only for package @lowdefy/format
## [3.20.1](https://github.com/lowdefy/lowdefy/compare/v3.20.0...v3.20.1) (2021-08-20)
**Note:** Version bump only for package @lowdefy/format
# [3.20.0](https://github.com/lowdefy/lowdefy/compare/v3.19.0...v3.20.0) (2021-08-20)
**Note:** Version bump only for package @lowdefy/format
# [3.19.0](https://github.com/lowdefy/lowdefy/compare/v3.18.1...v3.19.0) (2021-07-26)
**Note:** Version bump only for package @lowdefy/format
## [3.18.1](https://github.com/lowdefy/lowdefy/compare/v3.18.0...v3.18.1) (2021-06-30)
**Note:** Version bump only for package @lowdefy/format
# [3.18.0](https://github.com/lowdefy/lowdefy/compare/v3.17.2...v3.18.0) (2021-06-17)
**Note:** Version bump only for package @lowdefy/format
## [3.17.2](https://github.com/lowdefy/lowdefy/compare/v3.17.1...v3.17.2) (2021-06-11)
**Note:** Version bump only for package @lowdefy/format
## [3.17.1](https://github.com/lowdefy/lowdefy/compare/v3.17.0...v3.17.1) (2021-06-11)
**Note:** Version bump only for package @lowdefy/format
# [3.17.0](https://github.com/lowdefy/lowdefy/compare/v3.17.0-alpha.3...v3.17.0) (2021-06-11)
**Note:** Version bump only for package @lowdefy/format
# [3.17.0-alpha.3](https://github.com/lowdefy/lowdefy/compare/v3.17.0-alpha.2...v3.17.0-alpha.3) (2021-06-09)
**Note:** Version bump only for package @lowdefy/format
# [3.17.0-alpha.2](https://github.com/lowdefy/lowdefy/compare/v3.17.0-alpha.1...v3.17.0-alpha.2) (2021-06-09)
**Note:** Version bump only for package @lowdefy/format
# [3.17.0-alpha.1](https://github.com/lowdefy/lowdefy/compare/v3.17.0-alpha.0...v3.17.0-alpha.1) (2021-06-09)
**Note:** Version bump only for package @lowdefy/format
# [3.17.0-alpha.0](https://github.com/lowdefy/lowdefy/compare/v3.16.5...v3.17.0-alpha.0) (2021-06-09)
**Note:** Version bump only for package @lowdefy/format
## [3.16.5](https://github.com/lowdefy/lowdefy/compare/v3.16.4...v3.16.5) (2021-05-31)
**Note:** Version bump only for package @lowdefy/format
## [3.16.4](https://github.com/lowdefy/lowdefy/compare/v3.16.3...v3.16.4) (2021-05-28)
**Note:** Version bump only for package @lowdefy/format
## [3.16.3](https://github.com/lowdefy/lowdefy/compare/v3.16.2...v3.16.3) (2021-05-27)
**Note:** Version bump only for package @lowdefy/format
## [3.16.2](https://github.com/lowdefy/lowdefy/compare/v3.16.1...v3.16.2) (2021-05-26)
**Note:** Version bump only for package @lowdefy/format
## [3.16.1](https://github.com/lowdefy/lowdefy/compare/v3.16.0...v3.16.1) (2021-05-26)
**Note:** Version bump only for package @lowdefy/format
# [3.16.0](https://github.com/lowdefy/lowdefy/compare/v3.15.0...v3.16.0) (2021-05-26)
**Note:** Version bump only for package @lowdefy/format
# [3.15.0](https://github.com/lowdefy/lowdefy/compare/v3.14.1...v3.15.0) (2021-05-11)
**Note:** Version bump only for package @lowdefy/format
## [3.14.1](https://github.com/lowdefy/lowdefy/compare/v3.14.0...v3.14.1) (2021-04-28)
**Note:** Version bump only for package @lowdefy/format
# [3.14.0](https://github.com/lowdefy/lowdefy/compare/v3.13.0...v3.14.0) (2021-04-26)
**Note:** Version bump only for package @lowdefy/format
# [3.13.0](https://github.com/lowdefy/lowdefy/compare/v3.12.6...v3.13.0) (2021-04-16)
**Note:** Version bump only for package @lowdefy/format
## [3.12.6](https://github.com/lowdefy/lowdefy/compare/v3.12.5...v3.12.6) (2021-04-06)
**Note:** Version bump only for package @lowdefy/format
## [3.12.5](https://github.com/lowdefy/lowdefy/compare/v3.12.4...v3.12.5) (2021-03-31)
**Note:** Version bump only for package @lowdefy/format
## [3.12.4](https://github.com/lowdefy/lowdefy/compare/v3.12.3...v3.12.4) (2021-03-30)
**Note:** Version bump only for package @lowdefy/format
## [3.12.3](https://github.com/lowdefy/lowdefy/compare/v3.12.2...v3.12.3) (2021-03-26)
**Note:** Version bump only for package @lowdefy/format
## [3.12.2](https://github.com/lowdefy/lowdefy/compare/v3.12.1...v3.12.2) (2021-03-24)
**Note:** Version bump only for package @lowdefy/format
## [3.12.1](https://github.com/lowdefy/lowdefy/compare/v3.12.0...v3.12.1) (2021-03-24)
**Note:** Version bump only for package @lowdefy/format
# [3.12.0](https://github.com/lowdefy/lowdefy/compare/v3.11.4...v3.12.0) (2021-03-24)
**Note:** Version bump only for package @lowdefy/format
## [3.11.4](https://github.com/lowdefy/lowdefy/compare/v3.11.3...v3.11.4) (2021-03-19)
**Note:** Version bump only for package @lowdefy/format
## [3.11.3](https://github.com/lowdefy/lowdefy/compare/v3.11.2...v3.11.3) (2021-03-12)
**Note:** Version bump only for package @lowdefy/format
## [3.11.2](https://github.com/lowdefy/lowdefy/compare/v3.11.1...v3.11.2) (2021-03-11)
**Note:** Version bump only for package @lowdefy/format
## [3.11.1](https://github.com/lowdefy/lowdefy/compare/v3.11.0...v3.11.1) (2021-03-11)
**Note:** Version bump only for package @lowdefy/format
# [3.11.0](https://github.com/lowdefy/lowdefy/compare/v3.10.2...v3.11.0) (2021-03-11)
**Note:** Version bump only for package @lowdefy/format
## [3.10.2](https://github.com/lowdefy/lowdefy/compare/v3.10.1...v3.10.2) (2021-02-25)
**Note:** Version bump only for package @lowdefy/format
## [3.10.1](https://github.com/lowdefy/lowdefy/compare/v3.10.0...v3.10.1) (2021-02-19)
**Note:** Version bump only for package @lowdefy/format
# [3.10.0](https://github.com/lowdefy/lowdefy/compare/v3.9.0...v3.10.0) (2021-02-17)
**Note:** Version bump only for package @lowdefy/format
# [3.9.0](https://github.com/lowdefy/lowdefy/compare/v3.8.0...v3.9.0) (2021-02-16)
**Note:** Version bump only for package @lowdefy/format
# [3.8.0](https://github.com/lowdefy/lowdefy/compare/v3.7.2...v3.8.0) (2021-02-12)
### Features
* **operators:** Add _format operator. ([44839da](https://github.com/lowdefy/lowdefy/commit/44839daf959253660b6d3c97204898cad0e464fb))
## [3.7.2](https://github.com/lowdefy/lowdefy/compare/v3.7.1...v3.7.2) (2021-02-09)
### Bug Fixes
* Fix package lifecycle scripts. ([af7f3a8](https://github.com/lowdefy/lowdefy/commit/af7f3a8ea29763defb20cfb4f28afba3b56d981c))
## [3.7.1](https://github.com/lowdefy/lowdefy/compare/v3.7.0...v3.7.1) (2021-02-09)
**Note:** Version bump only for package @lowdefy/format
# [3.7.0](https://github.com/lowdefy/lowdefy/compare/v3.6.0...v3.7.0) (2021-02-09)
**Note:** Version bump only for package @lowdefy/format
# [3.6.0](https://github.com/lowdefy/lowdefy/compare/v3.5.0...v3.6.0) (2021-02-05)
**Note:** Version bump only for package @lowdefy/format
# [3.5.0](https://github.com/lowdefy/lowdefy/compare/v3.4.0...v3.5.0) (2021-02-05)
**Note:** Version bump only for package @lowdefy/format
# [3.4.0](https://github.com/lowdefy/lowdefy/compare/v3.3.0...v3.4.0) (2021-01-20)
**Note:** Version bump only for package @lowdefy/format
# [3.3.0](https://github.com/lowdefy/lowdefy/compare/v3.1.1...v3.3.0) (2021-01-18)
**Note:** Version bump only for package @lowdefy/format
# [3.2.0](https://github.com/lowdefy/lowdefy/compare/v3.1.1...v3.2.0) (2021-01-18)
**Note:** Version bump only for package @lowdefy/format
## [1.1.2](https://github.com/lowdefy/lowdefy/compare/@lowdefy/format@1.1.0...@lowdefy/format@1.1.2) (2020-12-15)
**Note:** Version bump only for package @lowdefy/format
## [1.1.1](https://github.com/lowdefy/lowdefy/compare/@lowdefy/format@1.1.0...@lowdefy/format@1.1.1) (2020-12-15)
**Note:** Version bump only for package @lowdefy/format
# 1.1.0 (2020-12-10)
### Bug Fixes
* **format:** getFormatter test update ([235d501](https://github.com/lowdefy/lowdefy/commit/235d5010cdd2fdfad3e09f944c98e052fba38ddd))
* **graphql:** fix readJsonFile for node 12 ([e43236b](https://github.com/lowdefy/lowdefy/commit/e43236bc1256a867247d8adb38d4d8ad7e700e33))
* **tests:** remove full-icu, test on both node 12 and 14 ([cf67d39](https://github.com/lowdefy/lowdefy/commit/cf67d39992bbe9940fe7b95d9bfccd315ee1b42a))
### Features
* **format:** init @lowdefy/format package ([f121e43](https://github.com/lowdefy/lowdefy/commit/f121e43671d2d56c569d8f98da634110f28ab0ad))

View File

@ -1,63 +0,0 @@
{
"name": "@lowdefy/rc-test",
"version": "3.22.0",
"license": "Apache-2.0",
"description": "",
"homepage": "https://lowdefy.com",
"keywords": [
"lowdefy"
],
"bugs": {
"url": "https://github.com/lowdefy/lowdefy/issues"
},
"contributors": [
{
"name": "Sam Tolmay",
"url": "https://github.com/SamTolmay"
},
{
"name": "Gerrie van Wyk",
"url": "https://github.com/Gervwyk"
}
],
"repository": {
"type": "git",
"url": "https://github.com/lowdefy/lowdefy.git"
},
"files": [
"dist/*"
],
"scripts": {
"babel": "babel src/location.js --out-dir dist",
"build": "yarn webpack && yarn babel",
"build:dev": "yarn webpack:dev && yarn babel",
"clean": "rm -rf dist",
"prepare": "yarn build",
"webpack": "webpack --config webpack.prod.js",
"webpack:dev": "webpack --config webpack.dev.js",
"start": "webpack serve --config webpack.dev.js"
},
"dependencies": {
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@babel/cli": "7.15.7",
"@babel/core": "7.15.8",
"@babel/preset-env": "7.15.8",
"@babel/preset-react": "7.16.0",
"babel-loader": "8.2.3",
"clean-webpack-plugin": "4.0.0",
"css-loader": "6.5.1",
"html-webpack-plugin": "5.5.0",
"serve": "13.0.2",
"style-loader": "3.3.1",
"webpack": "5.62.1",
"webpack-cli": "4.9.1",
"webpack-dev-server": "4.4.0",
"webpack-merge": "5.8.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@ -1,28 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<title>React App</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

View File

@ -1,10 +0,0 @@
import React from 'react';
import Icon from '@lowdefy/icons';
export default function App() {
return (
<div className="App">
<Icon />
</div>
);
}

View File

@ -1,23 +0,0 @@
/*
Copyright 2020-2021 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
const rootElement = document.getElementById('root');
ReactDOM.render(<App />, rootElement);

View File

@ -1,48 +0,0 @@
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
module.exports = {
entry: './src/index',
output: {
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
// TODO: FIXME: do NOT webpack 5 support with this
// x-ref: https://github.com/webpack/webpack/issues/11467
// waiting for babel fix: https://github.com/vercel/next.js/pull/17095#issuecomment-692435147
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['@babel/preset-react'],
},
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader', // translates CSS into CommonJS
},
],
},
],
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: './public/index.html',
}),
],
};

View File

@ -1,13 +0,0 @@
const { merge } = require('webpack-merge');
const webpack = require('webpack');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'development',
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
}),
],
});

View File

@ -1,12 +0,0 @@
const { merge } = require('webpack-merge');
const webpack = require('webpack');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production',
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
});