Skip to content

Commit

Permalink
Merge 4a8313e into 0e42dc2
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 6, 2023
2 parents 0e42dc2 + 4a8313e commit 78afd04
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/cspell-glob/src/GlobMatcher.test.ts
Expand Up @@ -8,7 +8,7 @@ import {
PathInterface,
} from './GlobMatcherTypes';

import mm = require('micromatch');
import mm from 'micromatch';

const defaultCwdWin32 = 'C:\\user\\home\\project\\testing';
const defaultCwdPosix = '/user/home/project/testing';
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-glob/src/GlobMatcher.ts
@@ -1,4 +1,4 @@
import mm = require('micromatch');
import mm from 'micromatch';
import * as Path from 'path';
import { normalizeGlobPatterns, doesRootContainPath, normalizeGlobToRoot } from './globHelper';
import { PathInterface, GlobMatch, GlobPattern, GlobPatternWithRoot, GlobPatternNormalized } from './GlobMatcherTypes';
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-glob/src/globHelper.test.ts
Expand Up @@ -14,7 +14,7 @@ import {
GlobPatternWithRoot,
PathInterface,
} from './GlobMatcherTypes';
import mm = require('micromatch');
import mm from 'micromatch';
import { NormalizeOptions } from '.';

const { rebaseGlob, trimGlob, isGlobalGlob } = __testing__;
Expand Down
1 change: 1 addition & 0 deletions packages/cspell-lib/package.json
Expand Up @@ -3,6 +3,7 @@
"version": "6.18.1",
"description": "A library of useful functions used across various cspell tools.",
"main": "dist/index.js",
"source": "./src/index.ts",
"typings": "dist/index.d.ts",
"files:comment": "Due to a lerna bug, patterns like `!**/*.map` are not getting recursively honored",
"files": [
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-pipe/package.json
Expand Up @@ -22,7 +22,8 @@
},
"exports": {
".": {
"require": "./dist/index.js"
"require": "./dist/index.js",
"import": "./dist/index.js"
},
"./index": "./dist/index.js",
"./index.js": "./dist/index.js",
Expand Down
14 changes: 11 additions & 3 deletions packages/cspell/package.json
Expand Up @@ -36,8 +36,9 @@
],
"scripts": {
"clean": "shx rm -rf dist coverage .tsbuildinfo",
"build": "pnpm run compile && pnpm run build-api",
"build-api": "rollup -c rollup.config.mjs",
"build": "pnpm run compile && pnpm run build-rollup",
"build-api": "pnpm run build-rollup",
"build-rollup": "rollup --config rollup.config.mjs",
"build-dev": "tsc -p tsconfig.dev.json",
"build:readme": "pnpm build:readme:help",
"build:readme:help": "pnpm build:readme:help:lint && pnpm build:readme:help:trace && inject-markdown README.md && prettier -w README.md",
Expand Down Expand Up @@ -75,6 +76,7 @@
"homepage": "https://streetsidesoftware.github.io/cspell/",
"dependencies": {
"@cspell/cspell-pipe": "workspace:*",
"@cspell/cspell-types": "workspace:*",
"chalk": "^4.1.2",
"commander": "^9.4.1",
"cspell-gitignore": "workspace:*",
Expand All @@ -96,6 +98,11 @@
"devDependencies": {
"@cspell/cspell-json-reporter": "workspace:*",
"@cspell/cspell-types": "workspace:*",
"@rollup/plugin-commonjs": "^23.0.7",
"@rollup/plugin-json": "^5.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.2.1",
"@rollup/plugin-typescript": "^9.0.2",
"@types/file-entry-cache": "^5.0.2",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^8.0.0",
Expand All @@ -107,6 +114,7 @@
"micromatch": "^4.0.5",
"minimatch": "^5.1.2",
"rollup": "^3.9.1",
"rollup-plugin-dts": "^5.1.0"
"rollup-plugin-dts": "^5.1.0",
"tslib": "^2.4.1"
}
}
105 changes: 103 additions & 2 deletions packages/cspell/rollup.config.mjs
@@ -1,6 +1,105 @@
/**
* Rollup Config.
*/

import rollupPluginNodeResolve from '@rollup/plugin-node-resolve';
import rollupPluginTypescript from '@rollup/plugin-typescript';
import rollupPluginJson from '@rollup/plugin-json';
import rollupPluginCommonjs from '@rollup/plugin-commonjs';
import rollupPluginTerser from '@rollup/plugin-terser';
import dts from 'rollup-plugin-dts';
import { readFileSync } from 'fs';

const pkgContent = readFileSync('./package.json', 'utf-8');
const pkg = JSON.parse(pkgContent);

const common = {
input: 'src/app.ts',

output: {
sourcemap: true,
},

external: [],

treeshake: {
annotations: true,
moduleSideEffects: [],
propertyReadSideEffects: false,
unknownGlobalSideEffects: false,
},
};

const commonTest = { ...common, input: 'src/app.test.ts' };

/**
* Get new instances of all the common plugins.
*/
function getPlugins(tsconfig = 'tsconfig.build.json') {
return [
rollupPluginTypescript({
tsconfig,
}),
rollupPluginNodeResolve({
mainFields: ['module', 'exports', 'es', 'es6', 'esm', 'main'],
extensions: ['.ts', '.js', '.mjs', '.node', '.json'],
preferBuiltins: true,
}),
rollupPluginCommonjs({
transformMixedEsModules: true,
}),
rollupPluginJson(),
rollupPluginTerser({
ecma: 2018,
warnings: true,
compress: { drop_console: false },
format: { comments: false },
sourceMap: true,
}),
];
}

const config = [
const copyright = `/*!
* ${pkg.name} v${pkg.version}
* Copyright ${new Date().getFullYear()} ${pkg.author}
* Released under the ${pkg.license} License
* ${pkg.homepage}
*/
`;

/**
* The common JS build.
*/
const cjs = {
...common,

output: {
...common.output,
file: pkg.main,
format: 'cjs',
banner: copyright,
},

plugins: getPlugins(),
};

/**
* The common JS test build.
*/
const cjsTest = {
...commonTest,

output: {
...commonTest.output,
file: './dist/app.test.js',
format: 'cjs',
banner: copyright,
},

plugins: getPlugins(),
};

const api = [
{
input: './dist/index.d.ts',
output: [{ file: './api/index.d.ts', format: 'es' }],
Expand All @@ -18,4 +117,6 @@ const config = [
},
];

export default config;
const configs = [cjs, cjsTest, ...api];

export default [...configs];
2 changes: 1 addition & 1 deletion packages/cspell/src/cli-reporter.ts
@@ -1,4 +1,4 @@
import chalk = require('chalk');
import chalk from 'chalk';
import type {
CSpellReporter,
Issue,
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell/src/commandCheck.ts
Expand Up @@ -3,7 +3,7 @@ import * as App from './application';
import { checkText } from './application';
import { BaseOptions } from './options';
import { CheckFailed } from './util/errors';
import chalk = require('chalk');
import chalk from 'chalk';

export function commandCheck(prog: Command): Command {
type CheckCommandOptions = BaseOptions;
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell/src/emitters/suggestionsEmitter.test.ts
@@ -1,6 +1,6 @@
import { emitSuggestionResult, EmitSuggestionOptions } from './suggestionsEmitter';
import type { SuggestedWord } from 'cspell-lib';
import chalk = require('chalk');
import chalk from 'chalk';

chalk.level = 0;

Expand Down
2 changes: 1 addition & 1 deletion packages/cspell/src/emitters/suggestionsEmitter.ts
@@ -1,5 +1,5 @@
import type { SuggestionsForWordResult, SuggestedWord } from 'cspell-lib';
import chalk = require('chalk');
import chalk from 'chalk';
import { padLeft, padWidth, width } from '../util/util';

export interface EmitSuggestionOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell/src/emitters/traceEmitter.ts
Expand Up @@ -2,7 +2,7 @@ import * as Path from 'path';
import strip from 'strip-ansi';
import { TraceResult } from '../application';
import { pad, width } from '../util/util';
import chalk = require('chalk');
import chalk from 'chalk';

export interface EmitTraceOptions {
/** current working directory */
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell/src/lint/lint.ts
Expand Up @@ -27,7 +27,7 @@ import { loadReporters, mergeReporters } from '../util/reporters';
import { getTimeMeasurer } from '../util/timer';
import * as util from '../util/util';
import { LintRequest } from './LintRequest';
import chalk = require('chalk');
import chalk from 'chalk';
import { getFeatureFlags } from '../featureFlags';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const npmPackage = require('../../package.json');
Expand Down
4 changes: 2 additions & 2 deletions packages/cspell/src/util/glob.test.ts
@@ -1,8 +1,8 @@
import * as path from 'path';
import { calcGlobs, normalizeGlobsToRoot } from './glob';
import { GlobMatcher } from 'cspell-glob';
import mm = require('micromatch');
import minimatch = require('minimatch');
import mm from 'micromatch';
import minimatch from 'minimatch';

const getStdinResult = {
value: '',
Expand Down
11 changes: 11 additions & 0 deletions packages/cspell/tsconfig.build.json
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist/",
"target": "ES2018"
},
"include": [
"./src"
]
}

0 comments on commit 78afd04

Please sign in to comment.