Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-ts-preprocess

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-ts-preprocess - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

LICENSE

151

package.json
{
"name": "svelte-ts-preprocess",
"version": "1.0.1",
"description": "Typescript preprocessor for Svelte 3",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"prepublish": "npm run lint",
"lint": "eslint src"
"name": "svelte-ts-preprocess",
"version": "1.1.0",
"description": "Typescript preprocessor for Svelte 3",
"keywords": [
"svelte",
"svelte3",
"preprocess"
],
"main": "dist/lib/svelte-ts-preprocess.js",
"typings": "dist/types/svelte-ts-preprocess.d.ts",
"files": [
"dist"
],
"author": "PaulMaly",
"contributors": ["Jungle <devex.soft@gmail.com>"],
"repository": {
"type": "git",
"url": "https://github.com/PaulMaly/svelte-ts-preprocess"
},
"bugs": {
"url": "https://github.com/PaulMaly/svelte-ts-preprocess/issues"
},
"homepage": "https://github.com/PaulMaly/svelte-ts-preprocess",
"license": "MIT",
"engines": {
"node": ">=6.0.0"
},
"scripts": {
"lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
"prebuild": "rimraf dist",
"build": "tsc && typedoc --out docs --target es6 --theme minimal --mode file src",
"start": "tsc -w",
"test": "jest --coverage",
"test:watch": "jest --coverage --watch",
"test:prod": "npm run lint && npm run test -- --no-cache",
"deploy-docs": "ts-node tools/gh-pages-publish",
"report-coverage": "cat ./coverage/lcov.info | coveralls",
"commit": "git-cz",
"semantic-release": "semantic-release",
"semantic-release-prepare": "ts-node tools/semantic-release-prepare",
"precommit": "lint-staged",
"travis-deploy-once": "travis-deploy-once"
},
"lint-staged": {
"{src,test}/**/*.ts": [
"prettier --write",
"git add"
]
},
"config": {},
"jest": {
"globals": {
"ts-jest": {
"tsConfig": "tsconfig.json"
}
},
"files": [
"src/index.js"
],
"repository": {
"type": "git",
"url": "git+https://github.com/PaulMaly/svelte-ts-preprocess.git"
"transform": {
".(ts|tsx)": "ts-jest"
},
"keywords": [
"svelte",
"preprocessors"
"testEnvironment": "node",
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"author": "PaulMaly",
"license": "MIT",
"bugs": {
"url": "https://github.com/PaulMaly/svelte-ts-preprocess/issues"
"coveragePathIgnorePatterns": [
"/node_modules/",
"/test/"
],
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 95,
"lines": 95,
"statements": 95
}
},
"homepage": "https://github.com/PaulMaly/svelte-ts-preprocess#readme",
"devDependencies": {
"eslint": "latest",
"eslint-plugin-import": "latest"
},
"dependencies": {
"colors": "latest",
"typescript": "latest"
}
}
"collectCoverageFrom": [
"src/*.{js,ts}"
]
},
"prettier": {
"semi": false,
"singleQuote": true
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"devDependencies": {
"@commitlint/cli": "^7.1.2",
"@commitlint/config-conventional": "^7.1.2",
"@types/jest": "^24.0.11",
"@types/node": "^11.13.6",
"colors": "^1.3.2",
"commitizen": "^3.0.0",
"coveralls": "^3.0.2",
"cross-env": "^5.2.0",
"cz-conventional-changelog": "^2.1.0",
"husky": "^1.3.1",
"jest": "^24.7.1",
"jest-config": "^24.7.1",
"lint-staged": "^8.0.0",
"lodash.camelcase": "^4.3.0",
"prettier": "^1.14.3",
"prompt": "^1.0.0",
"replace-in-file": "^4.0.0",
"rimraf": "^2.6.2",
"semantic-release": "^15.9.16",
"shelljs": "^0.8.3",
"travis-deploy-once": "^5.0.9",
"ts-jest": "^24.0.2",
"ts-node": "^8.1.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-config-standard": "^8.0.1",
"typedoc": "^0.14.2"
},
"dependencies": {
"typescript": "^3.4.4"
}
}

@@ -1,93 +0,54 @@

***!!! THIS PREPROCESSOR IS VERY EXPERIMENTAL !!!***
# Typescript preprocessor for Svelte 3
# svelte-ts-preprocess
## Install
Typescript type-checking preprocessor for [Svelte 3](https://v3.svelte.technology).
## Usage
Install with npm or yarn:
```bash
npm install --save-dev svelte-ts-preprocess
npm i svelte-ts-preprocess
```
Then import the plugin to your bundler config. Rollup example below.
## Rollup config
```javascript
import svelte from 'rollup-plugin-svelte';
import ts from 'svelte-ts-preprocess';
...
export default {
...
plugins: [
svelte({
...
preprocess: [
ts()
]
}),
...
]
};
```
import svelte from "rollup-plugin-svelte";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import { terser } from "rollup-plugin-terser";
Or use it with [svelte-preprocess](https://www.npmjs.com/package/svelte-preprocess):
import { preprocess } from "svelte-ts-preprocess";
```javascript
import svelte from 'rollup-plugin-svelte';
import ts from 'svelte-ts-preprocess';
import preprocess from 'svelte-preprocess';
...
const production = !process.env.ROLLUP_WATCH;
export default {
...
plugins: [
svelte({
...
preprocess: preprocess({
transformers: {
ts: ts().script
},
aliases: [
['ts', 'typescript']
]
})
}),
...
]
};
```
input: "src/main.js",
output: {
sourcemap: true,
format: "iife",
name: "app",
file: "public/bundle.js"
},
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file — better for performance
css: css => {
css.write("public/bundle.css");
},
preprocess: preprocess()
}),
## Options
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:
// https://github.com/rollup/rollup-plugin-commonjs
resolve(),
commonjs(),
By default Typescript options will be retrieved from *tsconfig.json* but you also can pass config object directly to the preprocessor function. You should choose one of this variants to get it work.
## Example
After preprocessor is setted up you'll be able to write Typescript code inside of component's script.
```html
<script lang="ts">
interface HTMLInputTarget {
"target": HTMLInputElement;
}
export let num: number = 0;
function handleChange(e: HTMLInputTarget) {
num = e.target.value;
}
</script>
<input on:change={handleChange} placeholper="Enter a number">
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
]
};
```
And will get type-checking warnings upon building process.
```bash
./src/App.svelte (9,2): Type 'string' is not assignable to type 'number'.
```
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc