Skip to content

Commit

Permalink
patch ESM acorn-jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Feb 10, 2024
1 parent e9a5c34 commit 76d446e
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions patches/acorn-jsx+5.3.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
diff --git a/node_modules/acorn-jsx/index.js b/node_modules/acorn-jsx/index.js
index 004e080..84378b0 100644
--- a/node_modules/acorn-jsx/index.js
+++ b/node_modules/acorn-jsx/index.js
@@ -1,6 +1,7 @@
'use strict';

-const XHTMLEntities = require('./xhtml');
+import * as acorn from "acorn";
+import XHTMLEntities from './xhtml.js';

const hexNumber = /^[\da-fA-F]+$/;
const decimalNumber = /^\d+$/;
@@ -70,7 +71,7 @@ function getQualifiedJSXName(object) {
getQualifiedJSXName(object.property);
}

-module.exports = function(options) {
+function acornJsx(options) {
options = options || {};
return function(Parser) {
return plugin({
@@ -82,16 +83,19 @@ module.exports = function(options) {

// This is `tokTypes` of the peer dep.
// This can be different instances from the actual `tokTypes` this plugin uses.
-Object.defineProperty(module.exports, "tokTypes", {
+Object.defineProperty(acornJsx, "tokTypes", {
get: function get_tokTypes() {
- return getJsxTokens(require("acorn")).tokTypes;
+ return getJsxTokens(acorn).tokTypes;
},
configurable: true,
enumerable: true
});

+
+export default acornJsx;
+
function plugin(options, Parser) {
- const acorn = Parser.acorn || require("acorn");
+ const acorn = Parser.acorn || acorn;
const acornJsx = getJsxTokens(acorn);
const tt = acorn.tokTypes;
const tok = acornJsx.tokTypes;
diff --git a/node_modules/acorn-jsx/xhtml.js b/node_modules/acorn-jsx/xhtml.js
index c152009..8f5aa79 100644
--- a/node_modules/acorn-jsx/xhtml.js
+++ b/node_modules/acorn-jsx/xhtml.js
@@ -1,4 +1,4 @@
-module.exports = {
+export default {
quot: '\u0022',
amp: '&',
apos: '\u0027',

0 comments on commit 76d446e

Please sign in to comment.