Skip to content

Commit

Permalink
deps: @nlib/eslint-config:3.17.25→3.17.28 @nlib/nodetool:0.4.1→1.0.0 …
Browse files Browse the repository at this point in the history
…@rollup/plugin-commonjs:17.1.0→21.0.1 @types/node:15.14.9→16.11.6 @types/selenium-webdriver:4.0.15→4.0.16 @typescript-eslint/eslint-plugin:4.31.1→5.3.0 @typescript-eslint/parser:4.31.1→5.3.0 esifycss:1.4.27→1.4.35 husky:4.3.8→7.0.4 lint-staged:11.1.2→11.2.6 postcss:8.3.8→8.3.11 rollup:2.56.3→2.59.0 selenium-webdriver:4.0.0-rc-1→4.0.0 systemjs:6.10.3→6.11.0 ts-node:9.1.1→10.4.0 typescript:4.4.3→4.4.4
  • Loading branch information
gjbkz committed Nov 4, 2021
1 parent 1be6ad8 commit 4cbfe1f
Show file tree
Hide file tree
Showing 17 changed files with 4,784 additions and 677 deletions.
2 changes: 2 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
npx @nlib/lint-commit --input $1
2 changes: 2 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
npx lint-staged
5,318 changes: 4,723 additions & 595 deletions package-lock.json

Large diffs are not rendered by default.

54 changes: 21 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"license": "Apache-2.0",
"engines": {
"node": ">=10"
"node": ">=12"
},
"repository": "kei-ito/rollup-plugin-embed-css",
"scripts": {
Expand All @@ -25,46 +25,47 @@
"build": "run-s build:tsc build:types",
"test": "ts-node test/index.ts",
"version": "run-s version:changelog version:add",
"version:changelog": "nlib-changelog --output CHANGELOG.md",
"version:changelog": "npx @nlib/changelog --output CHANGELOG.md",
"version:add": "git add ."
},
"dependencies": {
"@nlib/afs": "3.17.2",
"esifycss": "1.4.27",
"postcss": "8.3.8",
"esifycss": "1.4.35",
"postcss": "8.3.11",
"rollup-pluginutils": "2.8.2"
},
"devDependencies": {
"@nlib/changelog": "0.1.11",
"@nlib/eslint-config": "3.17.25",
"@nlib/eslint-config": "^3.17.28",
"@nlib/eslint-plugin": "^1.0.16",
"@nlib/githooks": "^0.1.0",
"@nlib/lint-commit": "0.1.8",
"@nlib/node-net": "3.17.2",
"@nlib/nodetool": "0.4.1",
"@rollup/plugin-commonjs": "17.1.0",
"@nlib/nodetool": "1.0.0",
"@rollup/plugin-commonjs": "21.0.1",
"@types/connect": "3.4.35",
"@types/node": "15.14.9",
"@types/selenium-webdriver": "4.0.15",
"@types/node": "16.11.6",
"@types/selenium-webdriver": "4.0.16",
"@types/serve-static": "1.13.10",
"@typescript-eslint/eslint-plugin": "4.31.1",
"@typescript-eslint/parser": "4.31.1",
"@typescript-eslint/eslint-plugin": "5.3.0",
"@typescript-eslint/parser": "5.3.0",
"connect": "3.7.0",
"eslint": "7.32.0",
"husky": "4.3.8",
"lint-staged": "11.1.2",
"lint-staged": "11.2.6",
"npm-run-all": "4.1.5",
"rollup": "2.56.3",
"selenium-webdriver": "4.0.0-rc-1",
"rollup": "2.59.0",
"selenium-webdriver": "4.0.0",
"serve-static": "1.14.1",
"systemjs": "6.10.3",
"ts-node": "9.1.1",
"typescript": "4.4.3"
"systemjs": "6.11.0",
"ts-node": "10.4.0",
"typescript": "4.4.4"
},
"eslintIgnore": [
"./test/**/*.js"
],
"eslintConfig": {
"extends": [
"@nlib"
"@nlib/eslint-config"
],
"env": {
"es6": true,
Expand Down Expand Up @@ -102,27 +103,14 @@
}
]
},
"husky": {
"hooks": {
"commit-msg": "nlib-lint-commit --input HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.ts": [
"eslint"
]
},
"renovate": {
"extends": [
":ignoreModulesAndTests",
":unpublishSafe",
":semanticPrefixChore",
":prNotPending",
":prConcurrentLimit10",
":prHourlyLimitNone",
":label(dependencies)",
":automergeMinor"
"github>nlibjs/renovate-config"
]
}
}
2 changes: 1 addition & 1 deletion src/DirectoryStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import * as rollup from 'rollup';
import type * as rollup from 'rollup';

export class DirectoryStore {

Expand Down
12 changes: 6 additions & 6 deletions src/cssPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as path from 'path';
import {AcornNode} from 'rollup';
import * as esifycss from 'esifycss';
import * as pluginUtils from 'rollup-pluginutils';
import type {AcornNode} from 'rollup';
import type * as esifycss from 'esifycss';
import type * as pluginUtils from 'rollup-pluginutils';
import {parseBundle} from './parseBundle';
import {IPluginCore} from './types';
import type {IPluginCore} from './types';

const removeRange = (
code: string,
range: esifycss.IRange,
range: esifycss.Range,
): string => `${code.slice(0, range.start)}${code.slice(range.end)}`;

export const cssPlugin = (
Expand Down Expand Up @@ -45,7 +45,7 @@ export const cssPlugin = (
bundle,
cssKey: session.configuration.cssKey,
}).chunks.forEach(({chunk, css}) => {
chunk.code = css.statements
chunk.code = css.expressionStatements
.sort((range1, range2) => range1.start < range2.start ? 1 : -1)
.reduce(removeRange, chunk.code);
cssList.push(css.ranges.map((range) => range.css).join('\n').trim());
Expand Down
2 changes: 1 addition & 1 deletion src/defaultPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {IPluginCore} from './types';
import type {IPluginCore} from './types';

export const defaultPlugin = (): IPluginCore => {
const throwError = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/embedCSSPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as path from 'path';
import * as esifycss from 'esifycss';
import * as rollup from 'rollup';
import type * as rollup from 'rollup';
import * as pluginUtils from 'rollup-pluginutils';
import {getFirstInput} from './getFirstInput';
import {cssPlugin} from './cssPlugin';
import {scriptPlugin} from './scriptPlugin';
import {IPluginOptions} from './types';
import type {IPluginOptions} from './types';
import {defaultPlugin} from './defaultPlugin';

export const embedCSSPlugin = (
Expand Down
2 changes: 1 addition & 1 deletion src/getChunkRelation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {IRollupChunkLike} from './types';
import type {IRollupChunkLike} from './types';

export const getChunkRelation = (
c1: IRollupChunkLike,
Expand Down
2 changes: 1 addition & 1 deletion src/getFirstInput.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as rollup from 'rollup';
import type * as rollup from 'rollup';

export const getFirstInput = (
input: rollup.InputOptions['input'],
Expand Down
2 changes: 1 addition & 1 deletion src/isOutputChunk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as rollup from 'rollup';
import type * as rollup from 'rollup';

export const isOutputChunk = (
x: rollup.OutputAsset | rollup.OutputChunk,
Expand Down
6 changes: 3 additions & 3 deletions src/parseBundle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as esifycss from 'esifycss';
import * as rollup from 'rollup';
import {IParseResult} from 'esifycss/lib/minifier/types';
import type * as rollup from 'rollup';
import type {ParseResult} from 'esifycss/lib/minifier/types';

export const parseBundle = (
{bundle, cssKey}: {
Expand All @@ -9,7 +9,7 @@ export const parseBundle = (
},
) => {
const tokens = new Map<string, number>();
const chunks: Array<{chunk: rollup.OutputChunk, css: IParseResult}> = [];
const chunks: Array<{chunk: rollup.OutputChunk, css: ParseResult}> = [];
const processed = new WeakSet<rollup.OutputChunk>();
const process = (
chunkOrName: rollup.OutputAsset | rollup.OutputChunk | string,
Expand Down
6 changes: 3 additions & 3 deletions src/scriptPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from 'path';
import * as esifycss from 'esifycss';
import * as pluginUtils from 'rollup-pluginutils';
import {IPluginCore} from './types';
import type * as pluginUtils from 'rollup-pluginutils';
import type {IPluginCore} from './types';
import {parseBundle} from './parseBundle';

export const scriptPlugin = (
Expand All @@ -23,7 +23,7 @@ export const scriptPlugin = (
bundle,
cssKey: session.configuration.cssKey,
});
const identifier = esifycss.createOptimizedIdentifier(tokens);
const identifier = esifycss.createOptimizedIdGenerator(tokens);
for (const {chunk, css} of chunks) {
let code = esifycss.minifyCSSInScript(chunk.code, css.ranges, identifier);
code = esifycss.setDictionary(code, identifier.idList);
Expand Down
8 changes: 4 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as esifycss from 'esifycss';
import * as rollup from 'rollup';
import type * as esifycss from 'esifycss';
import type * as rollup from 'rollup';

export interface IRollupChunkLike {
type: 'chunk',
Expand All @@ -13,8 +13,8 @@ export interface IRollupAssetLike {
fileName: string,
}

export interface IPluginOptions extends Omit<esifycss.ISessionOptions, 'css'> {
exclude?: Array<string | RegExp> | string | RegExp,
export interface IPluginOptions extends Omit<esifycss.SessionOptions, 'css'> {
exclude?: Array<RegExp | string> | RegExp | string,
css?: boolean | string,
}

Expand Down
2 changes: 1 addition & 1 deletion test/plugins.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import * as rollup from 'rollup';
import type * as rollup from 'rollup';
export const commonjs: () => rollup.Plugin;
15 changes: 12 additions & 3 deletions test/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ import * as serveStatic from 'serve-static';
import * as selenium from 'selenium-webdriver';
import * as chrome from 'selenium-webdriver/chrome';
import {getBaseURL, listenPort, closeServers} from '@nlib/node-net';
import {ITestResult} from './type';

interface TestResult {
className: Record<string, string>,
id: Record<string, string>,
keyframes: Record<string, string>,
style1: string,
style2: string,
style3: string,
style4: string,
}

export const startServer = async (
documentRoot: string,
Expand Down Expand Up @@ -32,7 +41,7 @@ export const startBrowser = async () => {

export const run = async (
directory: string,
): Promise<ITestResult> => {
): Promise<TestResult> => {
const [server, driver] = await Promise.all([startServer(directory), startBrowser()]);
const close = async () => {
// await new Promise((resolve) => setTimeout(resolve, 60000));
Expand All @@ -51,7 +60,7 @@ export const run = async (
await driver.wait(selenium.until.titleIs('Done'), 5000);
const result = await (await driver.findElement({css: 'body'})).getText();
await close();
return JSON.parse(result) as ITestResult;
return JSON.parse(result) as TestResult;
} catch (error: unknown) {
await close();
throw error;
Expand Down
22 changes: 0 additions & 22 deletions test/type.ts

This file was deleted.

0 comments on commit 4cbfe1f

Please sign in to comment.