Skip to content

Commit

Permalink
v2.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarCruz committed Dec 11, 2018
1 parent f09904b commit c1ecab5
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- @jsbits/deep-clone.
- Simple test with mocha and expect.js
- Brunch 2.10.0 in peerDependencies.
- TypeScript typings.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Alberto Martínez
Copyright (c) 2016-2018 Alberto Martínez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ With jscc, you have:

**IMPORTANT:**

From v2.8.3 the generation of source map is disabled by default, to fix issues with the behavior of many plugins that does not supports chained source maps. However, jscc will maintain the correct line numbers.
From v2.8.3, the generation of source map is disabled by default to solve issues with many plugins that does not supports chained source maps. With sourceMaps disabled, jscc will only keep the correct line numbers.

Please read more about this in [Using Source Maps](#using-source-maps).

Expand Down
117 changes: 117 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { any } from 'micromatch';

//
// Type definitions for rollup-plugin-jscc v1.0.x
// Definitions by aMarCruz
//
export = JsccPlugin

declare class JsccPlugin {
constructor (options: JsccPlugin.BrunchConf);

compile(param: JsccPlugin.File): Promise<JsccPlugin.File>;

pattern: RegExp;
staticPattern?: RegExp;
type: string;
}

declare namespace JsccPlugin {

type QuoteType = 'single' | 'double' | 'both'
type MatcherCB = (path: string) => boolean

interface BrunchConf {
[k: string]: any;
plugins: {
[k: string]: any;
jscc: Options;
}
}

interface Options {
/**
* String with the type of quotes to escape in the output of strings:
* 'single', 'double' or 'both'.
*
* It does not affects the output of regexes or strings contained in the
* JSON output of objects.
*/
escapeQuotes?: QuoteType;

/**
* Preserves the empty lines of the directives and blocks that were removed.
*
* Use this option with `sourceMap:false` if you are interested only in
* keeping the line numbering.
* @default true
*/
keepLines?: boolean;

/**
* Make a hi-res source-map, if `sourceMap:true` (the default).
* @default true
*/
mapHires?: boolean;

/**
* String, regex or array of strings or regexes matching the start of a directive.
* That is, the characters before the '#', usually the start of comments.
* @default /(?:\/[/*]|<!--) ?/
*/
prefixes?: string | RegExp | Array<string | RegExp>;

/**
* Must include a sourceMap?
* @default false
*/
sourceMaps?: boolean;

/**
* Alias for `sourceMaps`
* @deprecated
*/
sourceMap?: boolean;

/**
* [anymatch](https://github.com/es128/anymatch) of files for which sourcemap
* must be generated if `sourceMaps:true`.
* @default (JavaSctipt/TypeScript files)
*/
sourceMapFor?: string | RegExp | MatcherCB | Array<string | RegExp | MatcherCB>;

/**
* Plain object defining the variables used by jscc during the preprocessing.
*
* Each key is a varname matching the regex `_[0-9A-Z][_0-9A-Z]*`, the value
* can have any type.
*
* It has two predefined, readonly properties:
* - `_FILE` : Name of the source file, relative to the current directory
* - `_VERSION` : The version property in the package.json
*/
values?: { [k: string]: any };

/**
* [anymatch](https://github.com/es128/anymatch) of files that should not
* be processed.
*
* @default /^(bower_components|node_modules|vendor)\//
*/
ignore?: string | RegExp | MatcherCB | Array<string | RegExp | MatcherCB>;

/**
* Regular expression that matches the file paths you want to process.
*
* _Note:_ Do not use wildcards here.
* @default /\.(js|ts)x?$/
*/
pattern?: RegExp;
}

interface File {
data: string;
path: string;
map?: object;
}
}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "jscc-brunch",
"version": "2.10.0",
"description": "Conditional compilation and variable replacement for Brunch",
"description": "Conditional compilation and compile-time variable replacement for brunch",
"main": "./index.js",
"scripts": {
"pretest": "eslint index.js",
"pretest": "eslint index.js test/*.js",
"test": "mocha"
},
"engines": {
"node": ">=4.0",
"node": ">=4.2",
"npm": ">=3.0"
},
"keywords": [
Expand All @@ -18,9 +18,10 @@
"comments",
"compilation",
"javascript",
"typescript",
"es6",
"html5",
"preproccesor",
"preprocessor",
"stack",
"source map"
],
Expand All @@ -37,12 +38,12 @@
},
"license": "MIT",
"dependencies": {
"@jsbits/deep-clone": "^1.1.0",
"anymatch": "^2.0.0",
"flatten-brunch-map": "^2.8.0",
"jscc": "^1.1.0"
},
"devDependencies": {
"@jsbits/deep-clone": "^1.1.0",
"eslint": "^5.10.0",
"expect.js": "^0.3.1",
"mocha": "^5.2.0"
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const expect = require('expect.js')

describe('Plugin', function () {

// eslint-disable-next-line no-var
var options = {}
/** @type {Plugin.BrunchConf} */
var options = {} // eslint-disable-line no-var

beforeEach(function () {
options = {
Expand Down

0 comments on commit c1ecab5

Please sign in to comment.