Skip to content
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

doc: Remove some Scope methods for Babel 8 #2935

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions docs/v8-migration-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,27 @@ Other than the changes listed below, `@babel/parser` is affected by all the [AST
+ !functionExpressionPath.node.async
```

- Remove `Scope.prototype.traverse`, `Scope#parentBlock` and `Scope#hub` ([#16705](https://github.com/babel/babel/pull/16705))

__Migration__: Use `scope.path` methods and properties instead:

```diff
- scope.traverse(scopeRootNode, visitor, state)
+ scope.path.traverse(visitor, state)

- scope.parentBlock
+ scope.path.parent

- scope.hub
+ scope.path.hub
```

- Remove `Scope.prototype.getAllBindingsOfKind` and `Scope.prototype.toArray` ([#16705](https://github.com/babel/babel/pull/16705))

These methods have been removed as they are not used anymore in our code base.

__Migration__: You can copy&paste them from Babel 7's source to your plugin.

- Remove `hoist`, `updateSiblingKeys`, `call`, `setScope`, `resync`, `popContext`, `pushContext`, `setup`, `setKey` methods from `NodePath` ([#16655](https://github.com/babel/babel/pull/16655))

These methods are meant to be private so there is no real migration approach. If your plugin / build is broken by this change, feel free to open an issue and tell us how you use these methods and we can see what we can do after Babel 8 is released.
Expand All @@ -1223,9 +1244,10 @@ Other than the changes listed below, `@babel/parser` is affected by all the [AST

__Migration__: If you want to preserve the old behavior, you can use `NodePath#shouldSkip` to check whether a NodePath has been skipped before calling `NodePath#requeue()`.

- Remove `NodePath` methods starting with `_` ([#16504](https://github.com/babel/babel/pull/16504))
- Remove methods starting with `_` from `Scope` and `NodePath` ([#16504](https://github.com/babel/babel/pull/16504), [#16705](https://github.com/babel/babel/pull/16705))

```
```js
// NodePath.prototype
_assertUnremoved
_call
_callRemovalHooks
Expand All @@ -1246,6 +1268,10 @@ Other than the changes listed below, `@babel/parser` is affected by all the [AST
_resyncParent
_resyncRemoved
_verifyNodeList

// Scope.prototype
_renameFromMap
_generateUid
```

These methods are meant to be private so there is no real migration approach. If your plugin / build is broken by this change, feel free to open an issue and tell us how you use these methods and we can see what we can do after Babel 8 is released.
Expand Down
16 changes: 8 additions & 8 deletions js/minirepl.js
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was accidentally formatted, but it shouldn't matter.

Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import debounce from "lodash.debounce";

const miniReplExamples = [
"/(?i:a)b/",
`using Flavortown = from(#["Guy Fieri"]);`,
'using Flavortown = from(#["Guy Fieri"]);',
// use next(yourTurn) = throw "some code in here!"
// when we support extractors
`let yourTurn = throw "some code in here!"`,
'let yourTurn = throw "some code in here!"',
];

let inEditor;
let outEditor;

let runDemo = true;

const debouncedUpdate = debounce(function() {
const debouncedUpdate = debounce(function () {
compileCode(inEditor, outEditor);
}, 1000);

Expand Down Expand Up @@ -61,7 +61,7 @@ function simulateKeys(inEditor, outEditor, texts) {
function simulateKey(changingText) {
const delay = changingText ? 4000 : Math.round(Math.random() * 125) + 30;

timeout = setTimeout(function() {
timeout = setTimeout(function () {
if (!runDemo) {
if (timeout) {
clearTimeout(timeout);
Expand Down Expand Up @@ -142,7 +142,7 @@ function compileCode(sourceEditor, targetEditor) {
}

const BABEL_MINI_REPL = {
start: function() {
start: function () {
// don't init editor on mobile devices
if (isMobile()) return;

Expand All @@ -154,7 +154,7 @@ const BABEL_MINI_REPL = {
outEditor = setupEditor("hero-repl-out", true);
outEditor.renderer.$cursorLayer.element.style.display = "none";

inEditor.on("change", function() {
inEditor.on("change", function () {
if (!inEditor.getValue()) {
debouncedUpdate.cancel();
outEditor.setValue("");
Expand All @@ -169,13 +169,13 @@ const BABEL_MINI_REPL = {
}
});

setTimeout(function() {
setTimeout(function () {
document.querySelector(".hero-repl")?.classList.add("hero-repl--visible");
simulateKeys(inEditor, outEditor, miniReplExamples);
}, 150);
},

stopDemo: function() {
stopDemo: function () {
debouncedUpdate.cancel();
runDemo = false;
inEditor.setReadOnly(false);
Expand Down