Skip to content

Commit

Permalink
Move to a single package that targets ES2017 and ESM only (#421)
Browse files Browse the repository at this point in the history
* Move to a single package that targets ES2017 and ESM only

* include tests again

* cleanup

* reorg `src/tests/` folder

* adjustments to build and test setup

* Produce UMD format for those still not on ESM

It's easy enough to do, so no reason as yet not to.

* Use mode recent node

* No need for TS on this redirection package

* Prepare the redirection package

But now I have second thoughts as to whether it's a good idea in any case.

* Only include dist packages + types

* Update all imports to the new package

* Update old reference

* Fix yalc reference

* Update which files are included in the package

* Update copyright dates

* build project to es5 to able to run it with karma

* Merge pull request #432 from adrienpoly/fix-dispatch

Move dispatch helper from context to controller

* fix fixtures paths for use with karma

* fix `webpack-helpers` test

* don't specify karma plugins explictly

* freshen karma browser list

* Fix yarn lock

Co-authored-by: Marco Roth <[email protected]>
  • Loading branch information
dhh and marcoroth authored Sep 2, 2021
1 parent 486b456 commit 44943a3
Show file tree
Hide file tree
Showing 160 changed files with 2,647 additions and 5,945 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules/
docs/api/
*.log
*.tsbuildinfo
*.d.ts
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.2.0
16.7.0
File renamed without changes.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright © 2020 Basecamp, LLC.
Copyright © 2021 Basecamp, LLC.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Then write a compatible controller. Stimulus brings it to life automatically:

```js
// hello_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = [ "name", "output" ]
Expand Down Expand Up @@ -64,4 +64,4 @@ Continuous integration VMs generously provided by [Sauce Labs](https://saucelabs

---

© 2020 Basecamp, LLC.
© 2021 Basecamp, LLC.
10 changes: 5 additions & 5 deletions docs/handbook/02_hello_stimulus.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Let's create our first controller by extending the framework's built-in `Control

```js
// src/controllers/hello_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
}
Expand Down Expand Up @@ -78,7 +78,7 @@ One way is to put a log statement in the `connect()` method, which Stimulus call
Implement the `connect()` method in `hello_controller.js` as follows:
```js
// src/controllers/hello_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
connect() {
Expand All @@ -97,7 +97,7 @@ Start by renaming `connect()` to `greet()`:

```js
// src/controllers/hello_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
greet() {
Expand Down Expand Up @@ -147,7 +147,7 @@ Let's try it out. Open `hello_controller.js` and update it like so:

```js
// src/controllers/hello_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = [ "name" ]
Expand All @@ -170,7 +170,7 @@ That means we have an arsenal of standard refactoring techniques at our disposal

```js
// src/controllers/hello_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = [ "name" ]
Expand Down
2 changes: 1 addition & 1 deletion docs/handbook/03_building_something_real.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Next, create `src/controllers/clipboard_controller.js` and add an empty method `

```js
// src/controllers/clipboard_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
copy() {
Expand Down
6 changes: 3 additions & 3 deletions docs/handbook/05_managing_state.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Let's draft our controller. Create a new file, `src/controllers/slideshow_contro

```js
// src/controllers/slideshow_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = [ "slide" ]
Expand Down Expand Up @@ -143,7 +143,7 @@ Reload the page and verify that the console shows `1` and `Number`.
Now let's update `initialize()` and the other methods in the controller to use `this.indexValue` instead of `this.index`. Here's how the controller should look when we're done:

```js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = [ "slide" ]
Expand Down Expand Up @@ -182,7 +182,7 @@ We can define a Stimulus value change callback to clean up the repetition and sp
First, remove the `initialize()` method and define a new method, `indexValueChanged()`. Then remove the calls to `this.showCurrentSlide()` from `next()` and `previous()`:

```js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = [ "slide" ]
Expand Down
4 changes: 2 additions & 2 deletions docs/handbook/06_working_with_external_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Now we can implement our controller:

```js
// src/controllers/content_loader_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static values = { url: String }
Expand Down Expand Up @@ -139,7 +139,7 @@ Let's take a look at our final controller class:

```js
// src/controllers/content_loader_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static values = { url: String, refreshInterval: Number }
Expand Down
8 changes: 4 additions & 4 deletions docs/handbook/07_installing_stimulus.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Call webpack's [`require.context`](https://webpack.js.org/api/module-methods/#re

```js
// src/application.js
import { Application } from "stimulus"
import { Application } from "@hotwired/stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"

window.Stimulus = Application.start()
Expand Down Expand Up @@ -51,7 +51,7 @@ Stimulus works with other build systems, too, but without support for controller

```js
// src/application.js
import { Application } from "stimulus"
import { Application } from "@hotwired/stimulus"

import HelloController from "./controllers/hello_controller"
import ClipboardController from "./controllers/clipboard_controller"
Expand Down Expand Up @@ -124,7 +124,7 @@ If your application needs to support older browsers like Internet Explorer 11, i
```js
// src/application.js
import "@stimulus/polyfills"
import { Application } from "stimulus"
import { Application } from "@hotwired/stimulus"

window.Stimulus = Application.start()
//
Expand All @@ -140,7 +140,7 @@ You can override how Stimulus handles errors by defining `Application#handleErro

```js
// src/application.js
import { Application } from "stimulus"
import { Application } from "@hotwired/stimulus"
window.Stimulus = Application.start()

Stimulus.handleError = (error, message, detail) => {
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _Actions_ are how you handle DOM events in your controllers.

```js
// controllers/gallery_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
next(event) {
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ order: 00
A _controller_ is the basic organizational unit of a Stimulus application.

```js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
//
Expand Down Expand Up @@ -141,7 +141,7 @@ application.register("reference", ReferenceController)
You can also register a controller class inline instead of importing it from a module:

```js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

application.register("reference", class extends Controller {
//
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/css_classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Define CSS classes by logical name in your controller using the `static classes`

```js
// controllers/search_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static classes = [ "loading" ]
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/lifecycle_callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Special methods called _lifecycle callbacks_ allow you to respond whenever a con
<meta data-controller="callout" data-callout-text-value="connect()">

```js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
connect() {
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Define target names in your controller class using the `static targets` array:

```js
// controllers/search_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = [ "query", "errorMessage", "results" ]
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/values.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You can read and write [HTML data attributes](https://developer.mozilla.org/en-U

```js
// controllers/loader_controller.js
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static values = { url: String }
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = [ "source" ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ["item"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ["name"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller } from "stimulus"
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = [ "slide" ]
Expand Down
3 changes: 1 addition & 2 deletions packages/@stimulus/examples/index.js → examples/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "@stimulus/polyfills"
import { Application } from "@stimulus/core"
import { definitionsFromContext } from "@stimulus/webpack-helpers"
import { Application, definitionsFromContext } from "@hotwired/stimulus"
import Turbolinks from "turbolinks"

Turbolinks.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependencies": {
"@babel/core": "^7.5.5",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-runtime": "^7.14.5",
"@babel/preset-env": "^7.5.5",
"babel-loader": "^8.0.6",
"ejs": "^2.6.1",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% include layout/head %>

<p data-controller="clipboard" data-clipboard-supported-class="clipboard--supported">
<input data-clipboard-target="source" class="clipboard-source" type="text" value="https://stimulusjs.org" readonly>
<input data-clipboard-target="source" class="clipboard-source" type="text" value="https://stimulus.hotwired.dev" readonly>
<button data-action="clipboard#copy" class="clipboard-button">Copy</button>
</p>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 44943a3

Please sign in to comment.