diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000000..e5b6d8d6a6 --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000000..a8b33b210d --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", + "changelog": ["@svitejs/changesets-changelog-github-compact", { "repo": "sveltejs/svelte" }], + "commit": false, + "fixed": [], + "linked": [], + "access": "public", + "baseBranch": "version-4", + "bumpVersionsWithWorkspaceProtocolOnly": true, + "ignore": ["!(@sveltejs/*|svelte)"] +} diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 0000000000..7c25128a63 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,8 @@ +{ + "mode": "pre", + "tag": "next", + "initialVersions": { + "svelte": "4.0.0-next.1" + }, + "changesets": [] +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..8f3bad8107 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + branches: + - version-4 + +permissions: {} +jobs: + release: + # prevents this action from running on forks + if: github.repository == 'sveltejs/svelte' + permissions: + contents: write # to create release (changesets/action) + pull-requests: write # to create pull request (changesets/action) + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + with: + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits + fetch-depth: 0 + - uses: pnpm/action-setup@v2.2.4 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: pnpm + + - run: pnpm install --frozen-lockfile + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + version: pnpm changeset:version + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index e2e60ef732..1fc9c0d3cf 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "build": "pnpm -r build", "check": "pnpm -r check", "lint": "pnpm -r lint", - "format": "pnpm -r format" + "format": "pnpm -r format", + "changeset:version": "changeset version && pnpm -r generate:version && git add --all", + "release": "changeset release" }, "repository": { "type": "git", @@ -27,5 +29,5 @@ "prettier": "^2.8.8", "prettier-plugin-svelte": "^2.10.0" }, - "packageManager": "pnpm@8.4.0" + "packageManager": "pnpm@8.6.0" } diff --git a/packages/svelte/.gitignore b/packages/svelte/.gitignore index f09b147927..4b6e382652 100644 --- a/packages/svelte/.gitignore +++ b/packages/svelte/.gitignore @@ -1,6 +1,5 @@ *.map /src/compiler/compile/internal_exports.js -/src/shared/version.js /compiler.d.ts /compiler.cjs /index.d.ts diff --git a/packages/svelte/.prettierignore b/packages/svelte/.prettierignore index cc6961726d..3f6fbefc04 100644 --- a/packages/svelte/.prettierignore +++ b/packages/svelte/.prettierignore @@ -15,6 +15,7 @@ sites/svelte.dev/.vercel /test/**/_actual* /test/**/expected* /test/**/_output +/test/**/shards/*.test.js /types !rollup.config.js !vitest.config.js diff --git a/packages/svelte/CHANGELOG.md b/packages/svelte/CHANGELOG.md index 3e5cdb9f47..ef78702e88 100644 --- a/packages/svelte/CHANGELOG.md +++ b/packages/svelte/CHANGELOG.md @@ -13,7 +13,7 @@ - breaking: Minimum supported TypeScript version is now TypeScript 5 (it will likely work with lower versions, but we make no guarantees about that) ([#8488](https://github.com/sveltejs/svelte/pull/8488)) - breaking: Remove `svelte/register` hook, CJS runtime version and CJS compiler output ([#8613](https://github.com/sveltejs/svelte/pull/8613)) - breaking: Stricter types for `createEventDispatcher` (see PR for migration instructions) ([#7224](https://github.com/sveltejs/svelte/pull/7224)) -- breaking: Stricter types for `Action` and `ActionReturn` (see PR for migration instructions) ([#7224](https://github.com/sveltejs/svelte/pull/7224)) +- breaking: Stricter types for `Action` and `ActionReturn` (see PR for migration instructions) ([#7442](https://github.com/sveltejs/svelte/pull/7442)) - breaking: Stricter types for `onMount` - now throws a type error when returning a function asynchronously to catch potential mistakes around callback functions (see PR for migration instructions) ([#8136](https://github.com/sveltejs/svelte/pull/8136)) - breaking: Overhaul and drastically improve creating custom elements with Svelte (see PR for list of changes and migration instructions) ([#8457](https://github.com/sveltejs/svelte/pull/8457)) - breaking: Deprecate `SvelteComponentTyped` in favor of `SvelteComponent` ([#8512](https://github.com/sveltejs/svelte/pull/8512)) @@ -2654,4 +2654,4 @@ Set `style.cssText` rather than `style` ([#44](https://github.com/sveltejs/svelt ## 0.0.1 -- Just squatting on the package name +- Just squatting on the package name \ No newline at end of file diff --git a/packages/svelte/package.json b/packages/svelte/package.json index 323d672fa8..ade672ce35 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -74,18 +74,19 @@ "format": "prettier . --cache --plugin-search-dir=. --write", "check": "prettier . --cache --plugin-search-dir=. --check", "test": "vitest run && echo \"manually check that there are no type errors in test/types by opening the files in there\"", - "build": "rollup -c && npm run tsd", - "prepare": "npm run build", + "build": "rollup -c && pnpm tsd", + "prepare": "pnpm build", + "generate:version": "node ./scripts/generate-version.js", "dev": "rollup -cw", "posttest": "agadoo src/internal/index.js", - "prepublishOnly": "npm run lint && npm run build && npm test", + "prepublishOnly": "pnpm lint && pnpm build && pnpm test", "tsd": "node ./generate-types.js", "lint": "eslint \"{src,test}/**/*.{ts,js}\" --cache" }, "repository": { "type": "git", "url": "https://github.com/sveltejs/svelte.git", - "directory":"packages/svelte" + "directory": "packages/svelte" }, "keywords": [ "UI", diff --git a/packages/svelte/rollup.config.js b/packages/svelte/rollup.config.js index ec1eddca82..927f8e9495 100644 --- a/packages/svelte/rollup.config.js +++ b/packages/svelte/rollup.config.js @@ -5,14 +5,10 @@ import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import json from '@rollup/plugin-json'; -const require = createRequire(import.meta.url); -const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8')); +// runs the version generation as a side-effect of importing +import './scripts/generate-version.js'; -// Create auto-generated .js files -fs.writeFileSync( - './src/shared/version.js', - `/** @type {string} */\nexport const VERSION = '${pkg.version}';` -); +const require = createRequire(import.meta.url); const internal = await import('./src/runtime/internal/index.js'); fs.writeFileSync( diff --git a/packages/svelte/scripts/generate-version.js b/packages/svelte/scripts/generate-version.js new file mode 100644 index 0000000000..351ead1eca --- /dev/null +++ b/packages/svelte/scripts/generate-version.js @@ -0,0 +1,8 @@ +import fs from 'node:fs'; + +const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8')); + +fs.writeFileSync( + './src/shared/version.js', + `// generated during release, do not modify\n\n/** @type {string} */\nexport const VERSION = '${pkg.version}';\n` +); diff --git a/packages/svelte/src/shared/version.js b/packages/svelte/src/shared/version.js index 270af33e83..80a6d82b3c 100644 --- a/packages/svelte/src/shared/version.js +++ b/packages/svelte/src/shared/version.js @@ -1,2 +1,4 @@ +// generated during release, do not modify + /** @type {string} */ -export const VERSION = '4.0.0-next.0'; \ No newline at end of file +export const VERSION = '4.0.0-next.0'; diff --git a/packages/svelte/test/version/version.test.js b/packages/svelte/test/version/version.test.js new file mode 100644 index 0000000000..f6b3019786 --- /dev/null +++ b/packages/svelte/test/version/version.test.js @@ -0,0 +1,16 @@ +import { fileURLToPath } from 'node:url'; +import { assert, describe, it } from 'vitest'; +import { VERSION } from 'svelte/compiler'; +import { try_load_json } from '../helpers.js'; + +describe('svelte/compiler VERSION', () => { + it('should be the exact version from package.json'); + const pkg = try_load_json( + fileURLToPath(new URL('../../../../packages/svelte/package.json', import.meta.url)) + ); + assert.equal( + VERSION, + pkg.version, + 'VERSION export in src/shared/version.js does not equal version in package.json' + ); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3d9aa49c03..2c4d34f9da 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,8 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false importers: