Skip to content

Commit

Permalink
Merge pull request #677 from tighten/jbk/build-and-exports
Browse files Browse the repository at this point in the history
[2.x] Update exports and build formats
  • Loading branch information
bakerkretzmar authored Oct 14, 2023
2 parents 57b4d25 + 73e4d3c commit f134413
Show file tree
Hide file tree
Showing 17 changed files with 1,239 additions and 1,002 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ php artisan ziggy:generate --types
To make your IDE aware that Ziggy's `route()` helper is available globally, and to type it correctly, add a declaration like this in a `.d.ts` file somewhere in your project:

```ts
import routeFn from 'ziggy-js';
import { route as routeFn } from 'ziggy-js';

declare global {
var route: typeof routeFn;
Expand Down Expand Up @@ -334,7 +334,7 @@ export { Ziggy };
You can import Ziggy like any other JavaScript library. Without the `@routes` Blade directive Ziggy's config is not available globally, so it must be passed to the `route()` function manually:

```js
import route from '../../vendor/tightenco/ziggy/dist';
import { route } from '../../vendor/tightenco/ziggy/dist';
import { Ziggy } from './ziggy.js';

route('home', undefined, undefined, Ziggy);
Expand All @@ -349,7 +349,6 @@ export default defineConfig({
resolve: {
alias: {
'ziggy-js': 'vendor/tightenco/ziggy/dist',
// 'vendor/tightenco/ziggy/dist/vue.es' if using the Vue plugin
},
},
});
Expand All @@ -358,7 +357,7 @@ export default defineConfig({
Now your imports can be shortened to:

```js
import route from 'ziggy-js';
import { route } from 'ziggy-js';
```

### Vue
Expand Down Expand Up @@ -390,8 +389,6 @@ import App from './App.vue';
createApp(App).use(ZiggyVue, Ziggy);
```

If you use the Vue plugin with the `ziggy-js` import alias shown above, make sure to update the alias to `vendor/tightenco/ziggy/dist/vue.es`.

### React

Ziggy includes a `useRoute()` hook to make it easy to use the `route()` helper in your React app:
Expand Down
12 changes: 7 additions & 5 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

## Upgrading from `1.x` to `2.x`

- The package namespace has changed from `Tightenco\Ziggy` to `Tighten\Ziggy`. Note that the Composer package name, `tightenco/ziggy`, has not changed.
- The `makeDirectory` method of the `CommandRouteGenerator` class has been changed from `protected` to `private`. Overriding it is no longer supported.
- The JavaScript module now provides named exports only, and no default export. In practice, this means you should replace `import route from 'ziggy'` with `import { route } from 'ziggy'`. The Vue plugin is now also part of the default module, so instead of importing it separately from `'ziggy/vue'`, you can import it alongside the `route()` function: `import { route, ZiggyVue } from 'ziggy'`.
- The previously deprecated JavaScript `check()` method (e.g. `route().check('home')`) has been removed. Use `has()` instead.
- The package namespace has changed from `Tightenco\Ziggy` to `Tighten\Ziggy` (the Composer package name, `tightenco/ziggy`, has not changed).
- The `makeDirectory` method of the `CommandRouteGenerator` class is now private, overriding it is no longer supported.
- The deprecated JavaScript `check()` method (e.g. `route().check('home')`) has been removed. Use `has()` instead.
- Ziggy's JavaScript now provides named exports only, with no default export. Replace `import route from 'ziggy-js'` with `import { route } from 'ziggy-js'`.
- Ziggy's Vue plugin and React hook have moved to the root of the module. Replace imports from `ziggy-js/vue` or `ziggy-js/react` with imports directly from `ziggy-js` (e.g. `import { route, ZiggyVue } from 'ziggy-js'`).
- Ziggy now only includes ES Module builds. The default build, which [supports all modern browsers](https://github.com/developit/microbundle/?tab=readme-ov-file#-modern-mode-), is `./dist/index.js` (this is the default when you import from `ziggy-js` or `vendor/tightenco/ziggy/dist`). A legacy ES Module build using fewer new language features is included too, at `./dist/index.esm.js`. The third build, `./dist/route.umd.js`, is for internal use in Ziggy's `@routes` Blade directive.

## Upgrading from `0.9.x` to `1.x`

Expand Down Expand Up @@ -305,7 +307,7 @@ Ziggy `1.0` includes significant improvements and changes, most of which won't r
- `trimParam()`: use `.replace(/{|\??}/g, '')`.

<p></p>

See [#330](https://github.com/tighten/ziggy/pull/330)
</details>

Expand Down
2 changes: 1 addition & 1 deletion dist/index.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/index.m.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/index.modern.js

This file was deleted.

Loading

0 comments on commit f134413

Please sign in to comment.