-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Svelte widget #299
base: master
Are you sure you want to change the base?
Svelte widget #299
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "@parcel/config-default", | ||
"transformers": { | ||
"*.svelte": [ | ||
"parcel-transformer-svelte3-plus" | ||
] | ||
} | ||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,9 @@ | |
"build": "npm-run-all build:clean build:compile" | ||
}, | ||
"dependencies": { | ||
"django-s3-file-field": "file:../javascript-client" | ||
"django-s3-file-field": "file:../javascript-client", | ||
"svelte": "^4.2.0", | ||
"svelte-preprocess": "^5.0.4" | ||
}, | ||
"devDependencies": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort the |
||
"@parcel/transformer-sass": "^2.10.0", | ||
|
@@ -27,7 +29,11 @@ | |
"npm-run-all": "^4.1.5", | ||
"parcel": "^2.10.0", | ||
"rimraf": "^5.0.5", | ||
"typescript": "^5.2.2" | ||
"typescript": "^5.2.2", | ||
"@tsconfig/svelte": "^5.0.2", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove |
||
"parcel-transformer-svelte3-plus": "^0.2.10", | ||
"process": "^0.11.10", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
"svelte-check": "^3.5.0" | ||
}, | ||
"alias": { | ||
"buffer": false | ||
|
@@ -36,7 +42,13 @@ | |
"last 1 chrome version", | ||
"last 1 firefox version" | ||
], | ||
"@parcel/resolver-default": { | ||
"packageExports": true | ||
}, | ||
"eslintConfig": { | ||
"env": { | ||
"node": true | ||
}, | ||
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? We're compiling something for the browser, not Node. |
||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": true | ||
|
@@ -53,6 +65,20 @@ | |
], | ||
"rules": { | ||
"no-restricted-syntax": 0 | ||
} | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"typescript": {} | ||
} | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"**/*.ts", | ||
"**/*.js", | ||
"**/*.svelte" | ||
] | ||
} | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script lang="ts"> | ||
export let name: string = "friend"; | ||
console.log(arguments); | ||
</script> | ||
|
||
<h1>Hello {name}!</h1> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So, I'd suggest wrapping the HTML in |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import App from './App.svelte'; | ||
|
||
const targetInput = document.querySelector('input[data-s3fileinput]') as Element; | ||
const parent = targetInput.parentNode; | ||
const wrapper = document.createElement('div'); | ||
parent?.replaceChild(wrapper, targetInput); | ||
wrapper.appendChild(targetInput); | ||
|
||
const app = new App({ | ||
target: document.querySelector('input[data-s3fileinput]')?.parentNode as Element, | ||
props: { | ||
name: 'world', | ||
}, | ||
}); | ||
|
||
export default app; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
declare module '*.svelte' { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is any of this file necessary? Did you follow a tutorial that suggested creating this, or was it necessary to create by hand? |
||
interface ComponentOptions<Props> { | ||
target: HTMLElement; | ||
anchor?: HTMLElement; | ||
props?: Props; | ||
hydrate?: boolean; | ||
intro?: boolean; | ||
} | ||
|
||
interface Component<Props> { | ||
new (options: ComponentOptions<Props>): any; | ||
$set: (props: object) => any; | ||
$on: (event: string, callback: (event: CustomEvent) => any) => any; | ||
$destroy: () => any; | ||
render: (props?: object) => { | ||
html: string; | ||
css: { code: string; map?: string }; | ||
head?: string; | ||
}; | ||
} | ||
|
||
const component: Component<object>; | ||
|
||
export default component; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const sveltePreprocess = require('svelte-preprocess') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this file may not be necessary at all: https://github.com/HellButcher/parcel-transformer-svelte3-plus#configuration If we do need it, I'd rather use |
||
|
||
module.exports = { | ||
preprocess: sveltePreprocess() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
{ | ||
"extends": "@tsconfig/recommended/tsconfig.json", | ||
"extends": "@tsconfig/svelte/tsconfig.json", | ||
"include": [ | ||
"src/**/*" | ||
"src/**/*", | ||
"src/**/*.ts", | ||
"src/**/*.js", | ||
"src/**/*.svelte" | ||
Comment on lines
+5
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these necessary? Aren't they matched by |
||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This file is JSON5](https://parceljs.org/features/plugins/#.parcelrc), so let's use the same 2-space indent as other files.
Go ahead and add this file name to
.editorconfig
too.