Skip to content

Commit

Permalink
compile with tsc instead of rollup (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcath authored and pveyes committed May 9, 2019
1 parent bf25801 commit 49b0a82
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 300 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "htmr",
"version": "0.7.0",
"description": "Simple and lightweight (< 2kB) HTML to React converter that works in server and browser",
"main": "lib/index.js",
"main": "lib/server.js",
"browser": "lib/htmr.min.js",
"files": [
"lib"
],
"scripts": {
"build": "rollup -c",
"build": "tsc && rollup -c",
"clean": "rimraf lib",
"fmt": "prettier --write \"**/*.{js,md}\"",
"prepare": "npm-run-all clean build",
Expand Down
12 changes: 1 addition & 11 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,5 @@ export default [
terser(),
json(),
],
},
// commonJS
{
input: 'src/server.ts',
external: ['posthtml-parser', 'react', 'html-entities'],
output: [{ file: 'lib/index.js', format: 'cjs' }],
plugins: [
typescript2(),
json(),
],
},
}
];
4 changes: 1 addition & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function transform(node: Node, key: string, options: HtmrOptions): ChildComponen
return React.createElement(tag, props, children);
}

function convertServer(html: string, options = {} as HtmrOptions) {
export default function convertServer(html: string, options: Partial<HtmrOptions> = {}) {
if (typeof html !== 'string') {
throw new TypeError('Expected HTML string');
}
Expand All @@ -114,5 +114,3 @@ function convertServer(html: string, options = {} as HtmrOptions) {

return components[0];
}

module.exports = convertServer;
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
"outDir": "./lib", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
Expand All @@ -43,7 +43,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
Expand Down
Loading

0 comments on commit 49b0a82

Please sign in to comment.