Skip to content

Commit

Permalink
Update devDependencies, fix ESLint incompatibilities and remove extra…
Browse files Browse the repository at this point in the history
… @types/webpack dependency to avoid conflict with different version of their packages
  • Loading branch information
artembatura committed Jul 13, 2019
1 parent 75a3f57 commit 6438bb2
Show file tree
Hide file tree
Showing 22 changed files with 224 additions and 135 deletions.
24 changes: 10 additions & 14 deletions examples/react-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
"version": "0.4.0",
"private": true,
"scripts": {
"start": "webpack-spa start",
"prod": "webpack-spa build"
"start": "webpack-react start",
"build": "webpack-react build"
},
"dependencies": {
"react": "16.7.0",
"react-dom": "16.7.0"
"react": "16.8.6",
"react-dom": "16.8.6"
},
"devDependencies": {
"@types/node": "11.13.2",
"@types/react": "16.8.13",
"@types/react-dom": "16.8.3",
"@zero-scripts/extension.webpack-babel.react": "^0.4.0",
"@zero-scripts/extension.webpack-css": "^0.4.0",
"@zero-scripts/extension.webpack-eslint.react": "^0.4.0",
"@zero-scripts/extension.webpack-pwa": "^0.4.0",
"@zero-scripts/preset.webpack-spa": "^0.4.0",
"fork-ts-checker-webpack-plugin": "1.0.0-alpha.10",
"typescript": "3.4.2"
"@types/node": "12.0.0",
"@types/react": "16.8.16",
"@types/react-dom": "16.8.4",
"@zero-scripts/preset.webpack-spa.react": "^0.4.0",
"fork-ts-checker-webpack-plugin": "1.3.0",
"typescript": "3.4.5"
}
}
10 changes: 3 additions & 7 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
"version": "0.4.0",
"private": true,
"scripts": {
"start": "webpack-spa start",
"build": "webpack-spa build"
"start": "webpack-react start",
"build": "webpack-react build"
},
"dependencies": {
"react": "16.8.6",
"react-dom": "16.8.6"
},
"devDependencies": {
"@zero-scripts/extension.webpack-babel.react": "^0.4.0",
"@zero-scripts/extension.webpack-css": "^0.4.0",
"@zero-scripts/extension.webpack-eslint.react": "^0.4.0",
"@zero-scripts/extension.webpack-pwa": "^0.4.0",
"@zero-scripts/preset.webpack-spa": "^0.4.0"
"@zero-scripts/preset.webpack-spa.react": "^0.4.0"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"@types/get-port": "4.2.0",
"@types/jest": "24.0.15",
"@types/node": "12.6.2",
"@typescript-eslint/parser": "1.12.0",
"@typescript-eslint/eslint-plugin": "1.12.0",
"@typescript-eslint/parser": "1.12.0",
"babel-eslint": "10.0.2",
"eslint": "6.0.1",
"eslint-config-prettier": "6.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/config.webpack/src/WebpackConfigOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class WebpackConfigOptions extends AbstractOptionsContainer {
],
['useTypescript']
)
public readonly moduleFileExtensions: string[] = ['.json', '.js'];
public readonly moduleFileExtensions: string[] = ['.json', '.js', '.mjs'];

@Option<WebpackConfigOptions, 'jsFileExtensions', 'useTypescript'>(
({ externalValue, defaultValue, dependencies: { useTypescript } }) => [
Expand All @@ -52,7 +52,7 @@ export class WebpackConfigOptions extends AbstractOptionsContainer {
],
['useTypescript']
)
public readonly jsFileExtensions: string[] = ['js'];
public readonly jsFileExtensions: string[] = ['js', 'mjs'];

@Option<WebpackConfigOptions, 'isDev'>()
public isDev: boolean = false;
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/AbstractPreset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export abstract class AbstractPreset {

protected constructor(protected readonly standardExtensions: string[] = []) {
Object.keys(readPackageJson(data => data.devDependencies) as object)
.concat(standardExtensions)
.filter(packageIsExtension)
.concat(standardExtensions)
.map((packageName: string) => {
const ExtensionClass = (require(packageName) as {
default: ExtensionConstructor;
Expand All @@ -26,6 +26,7 @@ export abstract class AbstractPreset {
if (newBaseClass) {
const conflictExtension = this.extensions.find(ext => {
const iterableBaseClass = getBaseClass(ext.constructor, 1);

return (
ext.constructor.name === extension.constructor.name ||
(iterableBaseClass !== undefined &&
Expand Down
3 changes: 2 additions & 1 deletion packages/extension.webpack-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"@babel/runtime": "7.5.4",
"@zero-scripts/config.webpack": "^0.4.0",
"@zero-scripts/core": "^0.4.0",
"babel-loader": "8.0.6"
"babel-loader": "8.0.6",
"core-js": "3.0.1"
},
"devDependencies": {
"@zero-scripts/ts-config": "^0.4.0"
Expand Down
11 changes: 10 additions & 1 deletion packages/extension.webpack-babel/src/WebpackBabelExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ export class WebpackBabelExtension<
babelrc: false,
configFile: false,
presets: [
['@babel/preset-env', { loose: true, modules: false, targets: { esmodules: true }, useBuiltIns: 'usage' }],
[
'@babel/preset-env',
{
loose: true,
modules: false,
targets: { esmodules: true },
useBuiltIns: 'usage',
corejs: '3'
}
],
useTypescript && '@babel/preset-typescript',
...presets
].filter(Boolean),
Expand Down
5 changes: 3 additions & 2 deletions packages/extension.webpack-eslint.react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
"dependencies": {
"@zero-scripts/core": "^0.4.0",
"@zero-scripts/extension.webpack-eslint": "^0.4.0",
"eslint-config-react-app": "4.0.1",
"eslint-config-react-app-fresh": "4.0.2",
"eslint-plugin-flowtype": "3.11.1",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.14.2"
"eslint-plugin-react": "7.14.2",
"eslint-plugin-react-hooks": "1.7.0-alpha.0"
},
"devDependencies": {
"@zero-scripts/ts-config": "^0.4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export class WebpackEslintReactExtension extends WebpackEslintExtension<
WebpackEslintReactExtensionOptions
> {
public activate(preset: AbstractPreset): void {
this.optionsContainer.extends.push('eslint-config-react-app');
// TODO: we can back to eslint-config-react-app, when it's released
this.optionsContainer.extends.push('eslint-config-react-app-fresh');

this.optionsContainer.parserOptions = {
...this.optionsContainer.parserOptions,
Expand Down
5 changes: 3 additions & 2 deletions packages/extension.webpack-spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
"clean-webpack-plugin": "3.0.0",
"copy-webpack-plugin": "5.0.3",
"html-webpack-plugin": "4.0.0-beta.7",
"@artemir/friendly-errors-webpack-plugin": "1.8.0"
"@artemir/friendly-errors-webpack-plugin": "1.8.0",
"script-ext-html-webpack-plugin": "2.1.4"
},
"devDependencies": {
"@zero-scripts/ts-config": "^0.4.0",
"@types/clean-webpack-plugin": "0.1.3",
"@types/copy-webpack-plugin": "5.0.0",
"@types/html-webpack-plugin": "3.2.1"
"@types/script-ext-html-webpack-plugin": "2.1.0"
},
"publishConfig": {
"access": "public"
Expand Down
7 changes: 7 additions & 0 deletions packages/extension.webpack-spa/src/WebpackSpaExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import _HtmlWebpackPlugin from 'html-webpack-plugin';
import path from 'path';
import ScriptExtHtmlWebpackPlugin from 'script-ext-html-webpack-plugin';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const HtmlWebpackPlugin = _HtmlWebpackPlugin as any;
Expand Down Expand Up @@ -84,6 +85,12 @@ export class WebpackSpaExtension<
: false
}),
InsertPos.Start
)
.insertPlugin(
() =>
new ScriptExtHtmlWebpackPlugin({
module: /.*.m?js/gm
})
);
}
}
21 changes: 21 additions & 0 deletions packages/preset.webpack-spa.react/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Artem Batura

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions packages/preset.webpack-spa.react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @zero-scripts/preset.webpack-spa.react
12 changes: 12 additions & 0 deletions packages/preset.webpack-spa.react/bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env node

const { runCLI } = require('@zero-scripts/core');
const {
WebpackSpaReactPreset
} = require('@zero-scripts/preset.webpack-spa.react');

process.on('unhandledRejection', err => {
throw err;
});

runCLI(WebpackSpaReactPreset);
49 changes: 49 additions & 0 deletions packages/preset.webpack-spa.react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@zero-scripts/preset.webpack-spa.react",
"version": "0.4.0",
"author": {
"name": "Artem Batura",
"email": "artemir.q@gmail.com"
},
"repository": {
"type": "git",
"url": "https://github.com/artemirq/zero-scripts"
},
"bugs": {
"url": "https://github.com/artemirq/zero-scripts/issues"
},
"license": "MIT",
"main": "build/index.js",
"typings": "build/index.d.ts",
"files": [
"bin",
"build"
],
"bin": {
"webpack-react": "./bin/cli.js"
},
"dependencies": {
"@zero-scripts/core": "^0.4.0",
"@zero-scripts/extension.webpack-babel.react": "^0.4.0",
"@zero-scripts/extension.webpack-css": "^0.4.0",
"@zero-scripts/extension.webpack-eslint.react": "^0.4.0",
"@zero-scripts/extension.webpack-pwa": "^0.4.0",
"@zero-scripts/preset.webpack-spa": "^0.4.0"
},
"devDependencies": {
"@zero-scripts/ts-config": "^0.4.0"
},
"publishConfig": {
"access": "public"
},
"keywords": [
"zero-scripts",
"webpack",
"preset",
"@zero-scripts/preset.webpack-spa.react",
"babel",
"eslint",
"pwa",
"css"
]
}
13 changes: 13 additions & 0 deletions packages/preset.webpack-spa.react/src/WebpackSpaReactPreset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { WebpackPresetSpa } from '@zero-scripts/preset.webpack-spa';

export class WebpackSpaReactPreset extends WebpackPresetSpa {
constructor(defaultExtensions: string[] = []) {
super([
'@zero-scripts/extension.webpack-babel.react',
'@zero-scripts/extension.webpack-css',
'@zero-scripts/extension.webpack-eslint.react',
'@zero-scripts/extension.webpack-pwa',
...defaultExtensions
]);
}
}
1 change: 1 addition & 0 deletions packages/preset.webpack-spa.react/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './WebpackSpaReactPreset';
23 changes: 23 additions & 0 deletions packages/preset.webpack-spa.react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "@zero-scripts/ts-config",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
},
"references": [
{
"path": "../core"
},
{
"path": "../preset.webpack-spa"
},
{ "path": "../extension.webpack-babel.react" },
{
"path": "../extension.webpack-css"
},
{ "path": "../extension.webpack-eslint.react" },
{
"path": "../extension.webpack-pwa"
}
]
}
3 changes: 1 addition & 2 deletions packages/preset.webpack-spa/bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env node

const { runCLI } = require('@zero-scripts/core');

const { WebpackPresetSpa } = require('../build');
const { WebpackPresetSpa } = require('@zero-scripts/preset.webpack-spa');

process.on('unhandledRejection', err => {
throw err;
Expand Down
4 changes: 2 additions & 2 deletions packages/preset.webpack-spa/src/WebpackPresetSpa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { WebpackConfig } from '@zero-scripts/config.webpack';
import { AbstractPreset } from '@zero-scripts/core';

export class WebpackPresetSpa extends AbstractPreset {
public constructor() {
super(['@zero-scripts/extension.webpack-spa']);
public constructor(defaultExtensions: string[] = []) {
super(['@zero-scripts/extension.webpack-spa', ...defaultExtensions]);

this.scripts.set('start', async ({ options }) => {
process.env.NODE_ENV = 'development';
Expand Down
1 change: 1 addition & 0 deletions packages/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{ "path": "core" },
{ "path": "config.webpack" },
{ "path": "preset.webpack-spa" },
{ "path": "preset.webpack-spa.react" },
{ "path": "extension.webpack-babel" },
{ "path": "extension.webpack-babel.react" },
{ "path": "extension.webpack-css" },
Expand Down
Loading

0 comments on commit 6438bb2

Please sign in to comment.