-
-
Notifications
You must be signed in to change notification settings - Fork 115
Feat/esm #54
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
Feat/esm #54
Changes from all commits
fef6ad7
b57d419
ad58ef7
d736f01
b4b53df
1630c49
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,22 @@ | ||
--- | ||
'@sveltejs/vite-plugin-svelte': major | ||
--- | ||
|
||
feat: convert to es module with cjs fallback, use named export instead of default | ||
|
||
If you are using vite-plugin-svelte with require, you should switch to esm and import the named export "svelte". | ||
An example can be found in the usage section of the [readme](README.md) | ||
|
||
For existing esm configs update your import to use the new named export. | ||
|
||
```diff | ||
- import svelte from '@sveltejs/vite-plugin-svelte'; | ||
+ import { svelte } from '@sveltejs/vite-plugin-svelte'; | ||
``` | ||
|
||
continuing with cjs/require is discouraged but if you must use it, update your require statement to use the named export | ||
|
||
```diff | ||
- const svelte = require('@sveltejs/vite-plugin-svelte'); | ||
+ const { svelte } = require('@sveltejs/vite-plugin-svelte'); | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,45 @@ | ||
.DS_Store | ||
node_modules | ||
dist | ||
dist-ssr | ||
build | ||
TODOs.md | ||
# logs and temp | ||
*.log | ||
**/*.log | ||
*.cpuprofile | ||
**/*.cpuprofile | ||
temp | ||
explorations | ||
.idea | ||
**/temp | ||
*.tmp | ||
**/*.tmp | ||
|
||
# build and dist | ||
build | ||
**/build | ||
dist | ||
**/dist | ||
.svelte | ||
.svelte-kit | ||
**/.svelte | ||
**/.svelte-kit | ||
|
||
# env and local | ||
*.local | ||
*.cpuprofile | ||
**/*.local | ||
.env | ||
packages/**/pnpm-lock.yaml | ||
packages/**/package-lock.json | ||
packages/**/yarn.lock | ||
packages/**/dist | ||
packages/**/dist-ssr | ||
packages/**/build | ||
packages/**/node_modules | ||
temp/**/* | ||
**/.env | ||
|
||
#node_modules and pnpm | ||
node_modules | ||
**/node_modules | ||
# only workspace root has a lock | ||
**/pnpm-lock.yaml | ||
.pnpm-store | ||
**/.pnpm-store | ||
|
||
#ide | ||
.idea | ||
**/.idea | ||
.vscode | ||
**/.vscode | ||
|
||
# macos | ||
.DS_Store | ||
._.DS_Store | ||
**/.DS_Store | ||
**/._.DS_Store |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"private": true, | ||
"scripts": { | ||
"dev": "pnpm --dir packages/vite-plugin-svelte dev", | ||
"build:ci": "pnpm -r build-bundle --filter=./packages/vite-plugin-svelte", | ||
"build:ci": "pnpm -r build:ci --filter=./packages/vite-plugin-svelte", | ||
"build": "pnpm -r build --filter=\\!./packages/playground", | ||
"build:vite-plugin-svelte": "pnpm --dir packages/vite-plugin-svelte build", | ||
"test": "run-s test:serve test:build", | ||
|
@@ -15,9 +15,9 @@ | |
"test:ci:serve": "cross-env VITE_PRESERVE_BUILD_ARTIFACTS=1 jest --verbose --no-cache --runInBand --force-exit --ci --json --outputFile=\"temp/serve/jest-results.json\"", | ||
"test:ci:build": "cross-env VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 jest --verbose --no-cache --runInBand --force-exit --ci --json --outputFile=\"temp/build/jest-results.json\"", | ||
"lint": "eslint --ignore-path .gitignore '**/*.{js,ts,svelte,html,svx,md}'", | ||
"lint:fix": "pnpm lint -- --fix", | ||
"lint:fix": "pnpm run lint -- --fix", | ||
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. I think pnpm added a feature recently to allow you to drop the 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. that feature made me add it back, i wasn't sure if it would prefer a |
||
"format": "prettier --ignore-path .gitignore '**/*.{css,scss,svelte,html,js,ts,svx,md}' --check", | ||
"format:fix": "pnpm format -- --write", | ||
"format:fix": "pnpm run format -- --write", | ||
"fixup": "run-s lint:fix format:fix", | ||
"update-deps": "ncu -u && ncu -f \"/^@sveltejs\\/(?:kit|adapter)/\" --target=greatest -u", | ||
"release": "pnpm run build && pnpx --no changeset publish", | ||
|
@@ -26,26 +26,25 @@ | |
"devDependencies": { | ||
"@changesets/changelog-github": "^0.4.0", | ||
"@changesets/cli": "^2.16.0", | ||
"@microsoft/api-extractor": "^7.15.2", | ||
"@types/fs-extra": "^9.0.11", | ||
"@types/jest": "^26.0.23", | ||
"@types/node": "^15.12.0", | ||
"@types/node": "^15.12.2", | ||
"@types/semver": "^7.3.6", | ||
"@typescript-eslint/eslint-plugin": "^4.26.0", | ||
"@typescript-eslint/parser": "^4.26.0", | ||
"@typescript-eslint/eslint-plugin": "^4.26.1", | ||
"@typescript-eslint/parser": "^4.26.1", | ||
"chalk": "^4.1.1", | ||
"cross-env": "^7.0.3", | ||
"enquirer": "^2.3.6", | ||
"esbuild": "~0.12.5", | ||
"eslint": "^7.27.0", | ||
"esbuild": "^0.12.8", | ||
"eslint": "^7.28.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-html": "^6.1.2", | ||
"eslint-plugin-jest": "^24.3.6", | ||
"eslint-plugin-markdown": "^2.2.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"eslint-plugin-svelte3": "^3.2.0", | ||
"execa": "^5.1.0", | ||
"execa": "^5.1.1", | ||
"fs-extra": "^10.0.0", | ||
"husky": "^6.0.0", | ||
"jest": "^27.0.4", | ||
|
@@ -56,17 +55,17 @@ | |
"node-fetch": "^2.6.1", | ||
"npm-check-updates": "^11.6.0", | ||
"npm-run-all": "^4.1.5", | ||
"playwright-core": "^1.11.1", | ||
"pnpm": "^6.6.2", | ||
"prettier": "^2.3.0", | ||
"playwright-core": "^1.12.0", | ||
"pnpm": "^6.7.4", | ||
"prettier": "^2.3.1", | ||
"prettier-plugin-svelte": "^2.3.0", | ||
"rimraf": "^3.0.2", | ||
"semver": "^7.3.5", | ||
"sirv": "^1.0.12", | ||
"svelte": "^3.38.2", | ||
"ts-jest": "^27.0.2", | ||
"ts-jest": "^27.0.3", | ||
"typescript": "^4.3.2", | ||
"vite": "^2.3.6" | ||
"vite": "^2.3.7" | ||
}, | ||
"lint-staged": { | ||
"*.{js,ts,svelte,html,md,svx}": "eslint --fix", | ||
|
@@ -75,9 +74,9 @@ | |
] | ||
}, | ||
"engines": { | ||
"pnpm": ">=6", | ||
"pnpm": "^6.7.0", | ||
"yarn": "forbidden, use pnpm", | ||
"npm": "forbidden, use pnpm", | ||
"node": "^12.20 || ^14.13.1 || >= 16" | ||
"node": "^12.20 || ^14.13.1 || >= 16" | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# default svelte app template | ||
|
||
Created with `npx degit sveltejs/template` | ||
|
||
adapted to vite by moving index.html to root and replacing rollup config with vite | ||
|
||
use pnpm | ||
|
||
`pnpm dev` starts dev server | ||
`pnpm build` builds for production |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { getText } from '../../testUtils'; | ||
|
||
test('should render component imported via svelte field in package.json', async () => { | ||
expect(await getText('#test-id')).toBe('svelte field works'); | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.