Skip to content

Commit

Permalink
fix(deps): drop a few unnecessary dependencies (#643) (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anber committed Aug 14, 2020
1 parent 315d07a commit 47c8157
Show file tree
Hide file tree
Showing 59 changed files with 2,293 additions and 2,815 deletions.
2 changes: 2 additions & 0 deletions docs/BUNDLERS_INTEGRATION.md
Expand Up @@ -11,6 +11,8 @@ If you use Babel in your project, make sure to have a [config file for Babel](ht

## Bundlers

Please note, that `@babel/core` is a peer dependency of all loaders. Do not forget to add it to `devDependencies` list in your project.

### webpack

To use Linaria with webpack, in your webpack config, add `linaria/loader` under `module.rules`:
Expand Down
36 changes: 17 additions & 19 deletions package.json
Expand Up @@ -53,16 +53,15 @@
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-syntax-jsx": "^7.8.3",
"@babel/preset-env": "^7.9.0",
"@babel/preset-react": "^7.9.4",
"@babel/preset-typescript": "^7.9.0",
"@babel/cli": ">=7",
"@babel/plugin-proposal-class-properties": ">=7",
"@babel/plugin-syntax-jsx": ">=7",
"@babel/preset-env": ">=7",
"@babel/preset-react": ">=7",
"@babel/preset-typescript": ">=7",
"@callstack/eslint-config": "^10.0.1",
"@commitlint/config-conventional": "^8.3.4",
"@release-it/conventional-changelog": "^1.1.0",
"@types/babel__core": "^7.1.7",
"@types/cosmiconfig": "^5.0.3",
"@types/debug": "^4.1.5",
"@types/dedent": "^0.7.0",
Expand All @@ -82,6 +81,7 @@
"babel-jest": "^24.5.0",
"codecov": "^3.2.0",
"commitlint": "^8.3.5",
"dedent": "^0.7.0",
"del-cli": "^1.1.0",
"dtslint": "^0.9.8",
"eslint": "^7.6.0",
Expand All @@ -95,21 +95,17 @@
"typescript": "^3.9.7"
},
"dependencies": {
"@babel/core": "^7.9.0",
"@babel/generator": "^7.9.4",
"@babel/plugin-proposal-export-namespace-from": "^7.8.3",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.9.0",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/plugin-transform-template-literals": "^7.8.3",
"@babel/register": "^7.9.0",
"@babel/template": "^7.8.6",
"@babel/traverse": "^7.9.0",
"@babel/generator": ">=7",
"@babel/plugin-proposal-export-namespace-from": ">=7",
"@babel/plugin-syntax-dynamic-import": ">=7",
"@babel/plugin-transform-modules-commonjs": ">=7",
"@babel/plugin-transform-runtime": ">=7",
"@babel/plugin-transform-template-literals": ">=7",
"@babel/template": ">=7",
"@emotion/is-prop-valid": "^0.7.3",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"cosmiconfig": "^5.1.0",
"debug": "^4.1.1",
"dedent": "^0.7.0",
"enhanced-resolve": "^4.1.0",
"find-yarn-workspace-root": "^1.2.1",
"glob": "^7.1.3",
Expand All @@ -122,9 +118,11 @@
"source-map": "^0.6.1",
"strip-ansi": "^5.2.0",
"stylis": "^3.5.4",
"webpack": "^4.0.0",
"yargs": "^13.2.1"
},
"peerDependencies": {
"@babel/core": ">=7"
},
"resolutions": {
"git-raw-commits": "^2.0.3"
},
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/babel.test.ts
@@ -1,17 +1,17 @@
import { join } from 'path';
import * as babel from '@babel/core';
import { transformAsync } from '@babel/core';
import dedent from 'dedent';
import stripAnsi from 'strip-ansi';
import serializer from '../__utils__/linaria-snapshot-serializer';
import { StrictOptions } from '../babel/types';
import type { StrictOptions } from '../babel/types';

expect.addSnapshotSerializer(serializer);

const transpile = async (
input: string,
opts: Partial<StrictOptions> = { evaluate: false }
) =>
(await babel.transformAsync(input, {
(await transformAsync(input, {
babelrc: false,
presets: [[require.resolve('../babel'), opts]],
plugins: ['@babel/plugin-syntax-jsx'],
Expand Down
6 changes: 2 additions & 4 deletions src/__tests__/dynamic-import-noop.test.js
@@ -1,9 +1,7 @@
/* @flow */

const babel = require('@babel/core');
import { transformAsync } from '@babel/core';

it('replaces dynamic imports with a noop', async () => {
const { code } = await babel.transformAsync(
const { code } = await transformAsync(
`import('./foo').then(foo => foo.init())`,
{
plugins: [require.resolve('../babel/dynamic-import-noop')],
Expand Down
7 changes: 2 additions & 5 deletions src/__tests__/evaluators/extractor.test.ts
@@ -1,16 +1,13 @@
import path from 'path';
import dedent from 'dedent';
import * as babel from '@babel/core';
import type { TransformOptions } from '@babel/core';
import exctract from '../../babel/evaluators/extractor';

function getFileName() {
return path.resolve(__dirname, `../__fixtures__/test.js`);
}

function _shake(
opts?: babel.TransformOptions,
only: string[] = ['__linariaPreval']
) {
function _shake(opts?: TransformOptions, only: string[] = ['__linariaPreval']) {
return (
literal: TemplateStringsArray,
...placeholders: string[]
Expand Down
18 changes: 9 additions & 9 deletions src/__tests__/evaluators/preeval.test.ts
@@ -1,8 +1,8 @@
import { join } from 'path';
import * as babel from '@babel/core';
import { transformAsync } from '@babel/core';
import dedent from 'dedent';
import serializer from '../../__utils__/linaria-snapshot-serializer';
import { StrictOptions } from '../../babel/types';
import type { StrictOptions } from '../../babel/types';

expect.addSnapshotSerializer(serializer);

Expand All @@ -12,7 +12,7 @@ const options: Partial<StrictOptions> = {
};

const transpile = async (input: string) =>
(await babel.transformAsync(input, {
(await transformAsync(input, {
babelrc: false,
presets: [[require.resolve('../../babel/evaluators/preeval'), options]],
plugins: [
Expand All @@ -27,7 +27,7 @@ it('preserves classNames', async () => {
const { code } = await transpile(
dedent`
import { styled } from 'linaria/react';
const Component = styled.div\`\`;
`
);
Expand All @@ -39,7 +39,7 @@ it('handles locally named import', async () => {
const { code } = await transpile(
dedent`
import { styled as custom } from 'linaria/react';
const Component = custom.div\`\`;
`
);
Expand All @@ -52,7 +52,7 @@ it('replaces functional component', async () => {
const { code } = await transpile(
dedent`
import React from 'react';
const Component = (props) => ${div};
`
);
Expand All @@ -65,7 +65,7 @@ it('replaces class component', async () => {
const { code } = await transpile(
dedent`
import React from 'react';
class Component extends React.PureComponent {
render() {
return ${div};
Expand All @@ -82,9 +82,9 @@ it('replaces constant', async () => {
const { code } = await transpile(
dedent`
import React from 'react';
const tag = ${div};
const Component = (props) => tag;
`
);
Expand Down
7 changes: 2 additions & 5 deletions src/__tests__/evaluators/shaker.test.ts
@@ -1,16 +1,13 @@
import path from 'path';
import dedent from 'dedent';
import * as babel from '@babel/core';
import type { TransformOptions } from '@babel/core';
import shake from '../../babel/evaluators/shaker';

function getFileName() {
return path.resolve(__dirname, `../__fixtures__/test.js`);
}

function _shake(
opts?: babel.TransformOptions,
only: string[] = ['__linariaPreval']
) {
function _shake(opts?: TransformOptions, only: string[] = ['__linariaPreval']) {
return (
literal: TemplateStringsArray,
...placeholders: string[]
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/module.test.ts
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import dedent from 'dedent';
import * as babel from '@babel/core';
import Module from '../babel/module';
import { Evaluator, StrictOptions } from '../babel/types';
import type { Evaluator, StrictOptions } from '../babel/types';

beforeEach(() => Module.invalidate());

Expand Down
18 changes: 9 additions & 9 deletions src/__tests__/preval.test.ts
Expand Up @@ -5,7 +5,7 @@ import stripAnsi from 'strip-ansi';

import Module from '../babel/module';
import serializer from '../__utils__/linaria-snapshot-serializer';
import { Evaluator, StrictOptions } from '../babel/types';
import type { Evaluator, StrictOptions } from '../babel/types';

expect.addSnapshotSerializer(serializer);
async function transformAsync(
Expand Down Expand Up @@ -894,11 +894,11 @@ function run(
dedent`
import React from 'react'
import {css} from 'linaria'
const globalObj = {
opacity: 0.5,
};
const Styled1 = styled.p\`
opacity: ${'${globalObj.opacity}'}
\`
Expand All @@ -910,20 +910,20 @@ function run(
opacity: 0;
\`,
};
const classes2 = classes;
const MyComponent = styled\`
opacity: ${'${globalObj.opacity}'};
&:hover .${'${classes2.cell}'} {
opacity: ${'${classes.value}'};
}
${'${Styled1}'} {
font-size: 1;
}
\`;
return React.createElement(MyComponent);
}
`
Expand All @@ -938,7 +938,7 @@ function run(
dedent`
import React from 'react'
import {css} from 'linaria'
const color = 'red';
export default function Component() {
Expand All @@ -958,7 +958,7 @@ function run(
dedent`
import React from 'react'
import {css} from 'linaria'
const size = () => 5
export default function Component() {
const color = size()
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/transform.test.ts
Expand Up @@ -147,7 +147,9 @@ it('respects passed babel options', async () => {
},
}
)
).toThrow('Unexpected token');
).toThrow(
/Support for the experimental syntax 'jsx' isn't currently enabled/
);

expect(() =>
transform(
Expand Down
2 changes: 1 addition & 1 deletion src/__utils__/linaria-snapshot-serializer.ts
@@ -1,4 +1,4 @@
import { LinariaMetadata } from '../types';
import type { LinariaMetadata } from '../types';

type Serializer<T> = {
test: (value: any) => value is T;
Expand Down
3 changes: 3 additions & 0 deletions src/babel/babel.ts
@@ -0,0 +1,3 @@
import type core from '@babel/core';

export type Core = typeof core;
12 changes: 8 additions & 4 deletions src/babel/dynamic-import-noop.ts
@@ -1,12 +1,16 @@
import { types } from '@babel/core';
import { NodePath } from '@babel/traverse';
import type { Import } from '@babel/types';
import type { NodePath } from '@babel/traverse';
import syntax from '@babel/plugin-syntax-dynamic-import';
import type { Visitor } from '@babel/traverse';
import { Core } from './babel';

export default function dynamic({ types: t }: { types: typeof types }) {
export default function dynamic({
types: t,
}: Core): { inherits: any; visitor: Visitor } {
return {
inherits: syntax,
visitor: {
Import(path: NodePath<types.Import>) {
Import(path: NodePath<Import>) {
const noop = t.arrowFunctionExpression([], t.identifier('undefined'));

path.parentPath.replaceWith(
Expand Down
4 changes: 2 additions & 2 deletions src/babel/evaluators/buildOptions.ts
Expand Up @@ -2,8 +2,8 @@
* This file handles preparing babel config for Linaria preevaluation.
*/

import { PluginItem, TransformOptions } from '@babel/core';
import { StrictOptions } from '../types';
import type { PluginItem, TransformOptions } from '@babel/core';
import type { StrictOptions } from '../types';

type DefaultOptions = Partial<TransformOptions> & {
plugins: PluginItem[];
Expand Down

0 comments on commit 47c8157

Please sign in to comment.