Skip to content

Commit

Permalink
Fixing error when there are non svelte files (#26)
Browse files Browse the repository at this point in the history
* Fixing error when there are non svelte files

* Apply suggestions from code review

Co-authored-by: Eric Liu <ericyl.us@gmail.com>

Co-authored-by: neelneelneel <>
Co-authored-by: Eric Liu <ericyl.us@gmail.com>
  • Loading branch information
neelneelneel and metonym committed Feb 20, 2021
1 parent 5986dd8 commit 955845c
Show file tree
Hide file tree
Showing 15 changed files with 624 additions and 8 deletions.
2 changes: 2 additions & 0 deletions integration/glob/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/lib
/node_modules
40 changes: 40 additions & 0 deletions integration/glob/COMPONENT_API.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"total": 1,
"components": [
{
"moduleName": "Button",
"filePath": "src/button/Button.svelte",
"props": [
{
"name": "type",
"kind": "let",
"type": "string",
"value": "\"button2\"",
"isFunction": false,
"constant": false,
"reactive": false
},
{
"name": "primary",
"kind": "let",
"type": "boolean",
"value": "false",
"isFunction": false,
"constant": false,
"reactive": false
}
],
"slots": [
{
"name": "__default__",
"default": true,
"fallback": "Click me",
"slot_props": "{}"
}
],
"events": [{ "type": "forwarded", "name": "click", "element": "button" }],
"typedefs": [],
"rest_props": { "type": "Element", "name": "button" }
}
]
}
30 changes: 30 additions & 0 deletions integration/glob/COMPONENT_INDEX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Component Index

> 1 components exported from glob@0.0.1.
## Components

- [`Button`](#button)

---

## `Button`

### Props

| Prop name | Kind | Reactive | Type | Default value | Description |
| :-------- | :--------------- | :------- | :------------------- | ---------------------- | ----------- |
| type | <code>let</code> | No | <code>string</code> | <code>"button2"</code> | -- |
| primary | <code>let</code> | No | <code>boolean</code> | <code>false</code> | -- |

### Slots

| Slot name | Default | Props | Fallback |
| :-------- | :------ | :---- | :-------------------- |
| -- | Yes | -- | <code>Click me</code> |

### Events

| Event name | Type | Detail |
| :--------- | :-------- | :----- |
| click | forwarded | -- |
21 changes: 21 additions & 0 deletions integration/glob/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "glob",
"version": "0.0.1",
"private": true,
"svelte": "./src/index.js",
"module": "./lib/index.mjs",
"types": "./types/index.d.ts",
"scripts": {
"svelte-check": "svelte-check --workspace test",
"build": "rollup -c"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^10.0.0",
"@tsconfig/svelte": "^1.0.10",
"rollup": "^2.32.1",
"rollup-plugin-svelte": "^6.1.1",
"svelte": "^3.31.0",
"svelte-check": "^1.1.17",
"typescript": "^4.0.5"
}
}
27 changes: 27 additions & 0 deletions integration/glob/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pkg from "./package.json";
import svelte from "rollup-plugin-svelte";
import resolve from "@rollup/plugin-node-resolve";
import sveld from "sveld";

const production = !process.env.ROLLUP_WATCH;

export default {
input: "src/index.js",
output: { format: "es", file: pkg.module },
plugins: [
svelte(),
resolve(),
production &&
sveld({
glob:true,
markdown: true,
markdownOptions: {
onAppend: (type, document, components) => {
if (type === "h1")
document.append("quote", `${components.size} components exported from ${pkg.name}@${pkg.version}.`);
},
},
json: true,
}),
],
};
3 changes: 3 additions & 0 deletions integration/glob/src/action/Action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function () {
console.log('hello');
}
1 change: 1 addition & 0 deletions integration/glob/src/action/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Action } from "./Action.js";
8 changes: 8 additions & 0 deletions integration/glob/src/button/Button.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script>
export let type = "button2";
export let primary = false;
</script>

<button {...$$restProps} {type} class:primary on:click>
<slot>Click me</slot>
</button>
1 change: 1 addition & 0 deletions integration/glob/src/button/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Button } from "./Button.svelte";
2 changes: 2 additions & 0 deletions integration/glob/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Action } from "./action/";
export { Button } from "./button/";
3 changes: 3 additions & 0 deletions integration/glob/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@tsconfig/svelte",
}
21 changes: 21 additions & 0 deletions integration/glob/types/button/Button.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <reference types="svelte" />
import { SvelteComponentTyped } from "svelte";

export interface ButtonProps
extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["button"]> {
/**
* @default "button2"
*/
type?: string;

/**
* @default false
*/
primary?: boolean;
}

export default class Button extends SvelteComponentTyped<
ButtonProps,
{ click: WindowEventMap["click"] },
{ default: {} }
> {}
2 changes: 2 additions & 0 deletions integration/glob/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Action } from "./action/";
export { default as Button } from "./button/Button";
Loading

0 comments on commit 955845c

Please sign in to comment.