Skip to content

Commit 0182ad0

Browse files
authored
Revert ESM (#3839)
1 parent 72cf181 commit 0182ad0

File tree

186 files changed

+4134
-1419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+4134
-1419
lines changed

.circleci/api-comment.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,7 @@ async function run() {
5353

5454
if (pr != null) {
5555
let commentId = await findDifferComment(pr);
56-
let diffs;
57-
try {
58-
diffs = fs.readFileSync('/tmp/dist/ts-diff.txt');
59-
} catch (e) {
60-
console.log('No TS Diff output to run on.')
61-
return;
62-
}
56+
let diffs = fs.readFileSync('/tmp/dist/ts-diff.txt');
6357
if (diffs.length > 0) {
6458
if (commentId != null) {
6559
// delete existing comment

.circleci/config.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ executors:
2727
CACHE_VERSION: v1
2828
working_directory: ~/react-spectrum
2929

30-
rsp-xlarge-nodeupdate:
31-
docker:
32-
- image: cimg/node:16.18.0
33-
resource_class: xlarge
34-
environment:
35-
CACHE_VERSION: v1
36-
working_directory: ~/react-spectrum
37-
3830
jobs:
3931
install:
4032
executor: rsp-large
@@ -214,20 +206,6 @@ jobs:
214206
- store_artifacts:
215207
path: ~/junit
216208

217-
218-
test-esm:
219-
executor: rsp-xlarge-nodeupdate
220-
steps:
221-
- restore_cache:
222-
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
223-
224-
- run:
225-
name: test
226-
command: |
227-
make build
228-
yarn lerna run prepublishOnly
229-
node --loader ./scripts/esm-support/loader.mjs ./scripts/esm-support/testESM.mjs
230-
231209
lint:
232210
executor: rsp
233211
steps:
@@ -472,9 +450,6 @@ workflows:
472450
- test-17:
473451
requires:
474452
- install-17
475-
- test-esm:
476-
requires:
477-
- install
478453
- lint:
479454
requires:
480455
- install
@@ -530,7 +505,6 @@ workflows:
530505
- test-16
531506
- test-ssr-17
532507
- test-17
533-
- test-esm
534508
- storybook
535509
- storybook-16
536510
- storybook-17

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ node_modules
77
packages/*/*/dist
88
packages/react-aria/dist
99
packages/react-stately/dist
10-
packages/dev/storybook-builder-parcel/preview.js
10+
packages/dev/storybook-builder-preview/preview.js

babel-esm.config.json

Lines changed: 0 additions & 61 deletions
This file was deleted.

bin/imports.js

Lines changed: 66 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -16,78 +16,73 @@ const fs = require('fs');
1616
const Module = require('module');
1717
const substrings = ['-', '+'];
1818

19-
module.exports = {
20-
meta: {
21-
fixable: 'code'
22-
},
23-
create: function (context) {
24-
let processNode = (node) => {
25-
if (!node.source || node.importKind === 'type') {
26-
return;
27-
}
28-
29-
let source = node.source.value.replace(/^[a-z]+:/, '');
30-
if (source.startsWith('.') || Module.builtinModules.includes(source)) {
31-
return;
32-
}
33-
34-
// Split the import specifier on slashes. If it starts with an @ then it's
35-
// a scoped package, otherwise just take the first part.
36-
let parts = source.split('/');
37-
let pkgName = source.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
38-
39-
// Search for a package.json starting from the current filename
40-
let pkgPath = findUp.sync('package.json', {cwd: path.dirname(context.getFilename())});
41-
if (!pkgPath) {
42-
return;
43-
}
44-
45-
let pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
46-
47-
// The only dev dependency should be spectrum-css.
48-
if (exists(pkg.devDependencies, pkgName) && pkgName === '@adobe/spectrum-css-temp') {
49-
return;
50-
}
51-
52-
if (!exists(pkg.dependencies, pkgName) && !exists(pkg.peerDependencies, pkgName) && pkgName !== pkg.name) {
53-
context.report({
54-
node,
55-
message: `Missing dependency on ${pkgName}.`,
56-
fix(fixer) {
57-
// Attempt to find a package in the monorepo. If the dep is for an external library,
58-
// then we cannot auto fix it because we don't know the version to add.
59-
let depPath = __dirname + '/../packages/' + pkgName + '/package.json';
60-
if (!fs.existsSync(depPath)) {
61-
return;
62-
}
63-
64-
let depPkg = JSON.parse(fs.readFileSync(depPath, 'utf8'));
65-
let pkgVersion = substrings.some(v => depPkg.version.includes(v)) ? depPkg.version : `^${depPkg.version}`;
66-
67-
if (pkgName === '@react-spectrum/provider') {
68-
pkg.peerDependencies = insertObject(pkg.peerDependencies, pkgName, pkgVersion);
69-
} else {
70-
pkg.dependencies = insertObject(pkg.dependencies, pkgName, pkgVersion);
71-
}
72-
73-
fs.writeFileSync(pkgPath, JSON.stringify(pkg, false, 2) + '\n');
74-
75-
// Fake fix so eslint doesn't show the error.
76-
return {
77-
range: [0, 0],
78-
text: ''
79-
};
19+
module.exports = function (context) {
20+
let processNode = (node) => {
21+
if (!node.source || node.importKind === 'type') {
22+
return;
23+
}
24+
25+
let source = node.source.value.replace(/^[a-z]+:/, '');
26+
if (source.startsWith('.') || Module.builtinModules.includes(source)) {
27+
return;
28+
}
29+
30+
// Split the import specifier on slashes. If it starts with an @ then it's
31+
// a scoped package, otherwise just take the first part.
32+
let parts = source.split('/');
33+
let pkgName = source.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
34+
35+
// Search for a package.json starting from the current filename
36+
let pkgPath = findUp.sync('package.json', {cwd: path.dirname(context.getFilename())});
37+
if (!pkgPath) {
38+
return;
39+
}
40+
41+
let pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
42+
43+
// The only dev dependency should be spectrum-css.
44+
if (exists(pkg.devDependencies, pkgName) && pkgName === '@adobe/spectrum-css-temp') {
45+
return;
46+
}
47+
48+
if (!exists(pkg.dependencies, pkgName) && !exists(pkg.peerDependencies, pkgName)) {
49+
context.report({
50+
node,
51+
message: `Missing dependency on ${pkgName}.`,
52+
fix(fixer) {
53+
// Attempt to find a package in the monorepo. If the dep is for an external library,
54+
// then we cannot auto fix it because we don't know the version to add.
55+
let depPath = __dirname + '/../packages/' + pkgName + '/package.json';
56+
if (!fs.existsSync(depPath)) {
57+
return;
8058
}
81-
});
82-
}
83-
};
84-
85-
return {
86-
ImportDeclaration: processNode,
87-
ExportNamedDeclaration: processNode,
88-
ExportAllDeclaration: processNode
89-
};
90-
}
59+
60+
let depPkg = JSON.parse(fs.readFileSync(depPath, 'utf8'));
61+
let pkgVersion = substrings.some(v => depPkg.version.includes(v)) ? depPkg.version : `^${depPkg.version}`;
62+
63+
if (pkgName === '@react-spectrum/provider') {
64+
pkg.peerDependencies = insertObject(pkg.peerDependencies, pkgName, pkgVersion);
65+
} else {
66+
pkg.dependencies = insertObject(pkg.dependencies, pkgName, pkgVersion);
67+
}
68+
69+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, false, 2) + '\n');
70+
71+
// Fake fix so eslint doesn't show the error.
72+
return {
73+
range: [0, 0],
74+
text: ''
75+
};
76+
}
77+
});
78+
}
79+
};
80+
81+
return {
82+
ImportDeclaration: processNode,
83+
ExportNamedDeclaration: processNode,
84+
ExportAllDeclaration: processNode
85+
};
9186
};
9287

9388
function exists(deps, name) {

examples/rsp-next-ts/next.config.mjs renamed to examples/rsp-next-ts/next.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import ntm from 'next-transpile-modules';
2-
const withTM = ntm([
1+
const withTM = require("next-transpile-modules")([
32
"@adobe/react-spectrum",
43
"@react-spectrum/actiongroup",
54
"@react-spectrum/badge",
@@ -52,10 +51,9 @@ const withTM = ntm([
5251
"@spectrum-icons/workflow",
5352
]);
5453

55-
let result = withTM({
54+
module.exports = withTM({
5655
basePath:
5756
process.env.VERDACCIO && process.env.CIRCLE_SHA1
5857
? `/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/next`
5958
: "",
6059
});
61-
export default result;

examples/rsp-next-ts/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"start": "next start",
1111
"lint": "next lint"
1212
},
13-
"type": "module",
1413
"dependencies": {
1514
"@adobe/react-spectrum": "^3.22.0",
1615
"@react-spectrum/color": "^3.0.0-beta.16",

0 commit comments

Comments
 (0)