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

ESM all the things #12161

Merged
merged 27 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1c63552
ESM all the things
lucacasonato Aug 23, 2021
9bc2ce2
Merge branch 'main' into esm_all_the_things
queengooborg Apr 26, 2022
4074a80
Fix formatting
queengooborg Apr 26, 2022
d7aeb66
Add missing import
queengooborg Apr 26, 2022
9ffd02f
Fix remaining files
queengooborg Apr 26, 2022
4b957ee
Install es-main package
queengooborg Apr 26, 2022
f4c1bc0
Utilize es-main package
queengooborg Apr 26, 2022
ba8ff3c
Import yargs hideBin() helper
queengooborg Apr 26, 2022
32708b2
Fix exports
queengooborg Apr 26, 2022
d1ff939
Wrap yargs/executable script parts within esMain
queengooborg Apr 26, 2022
3e29fe6
Fix yargs
queengooborg Apr 26, 2022
3d33917
Fix imports
queengooborg Apr 26, 2022
2fee2f2
Move main function down in diff-features
queengooborg Apr 26, 2022
7f3b30b
Fix exports for diff-features
queengooborg Apr 26, 2022
dd208db
Fix release-notes script
queengooborg Apr 26, 2022
1de266c
Fix enumerate-features
queengooborg Apr 26, 2022
3b94eaa
Merge branch 'main' into esm_all_the_things
queengooborg May 4, 2022
ba01cda
review comments
lucacasonato May 5, 2022
7fd90a3
Merge branch 'main' into esm_all_the_things
queengooborg May 18, 2022
3bd064d
Fix imports and exports
queengooborg May 18, 2022
a00de8a
Fix imports/exports, cleanup code, cleanup diff, fix scripts
queengooborg May 18, 2022
f4db6ed
Fix import
queengooborg May 18, 2022
9be1335
Use import assertion for browser-specs (we're using NodeJS v16)
queengooborg May 18, 2022
35f0457
Fix ESLint
queengooborg May 18, 2022
6acf25a
Merge branch 'main' into esm_all_the_things
queengooborg May 18, 2022
c6c687c
Fix unittest
queengooborg May 18, 2022
66d49fa
Fix unittest (again)
queengooborg May 18, 2022
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
3 changes: 3 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["@babel/plugin-syntax-import-assertions"]
}
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"env": {
"commonjs": true,
"es6": true,
"jest": true,
"node": true
Expand All @@ -10,7 +9,9 @@
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 2020
"ecmaVersion": 2020,
"sourceType": "module"
}
}
6 changes: 1 addition & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* This file is a part of @mdn/browser-compat-data
* See LICENSE file for more information. */

/// <reference path="./types.d.ts"/>
import { CompatData } from './types';

// This is necessary to have intellisense in projects which
// import data from this package.
declare const compatData: CompatData;
export = compatData;
export default CompatData;
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* This file is a part of @mdn/browser-compat-data
* See LICENSE file for more information. */

'use strict';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
caugner marked this conversation as resolved.
Show resolved Hide resolved

const fs = require('fs');
const path = require('path');
const { fdir } = require('fdir');
import { fdir } from 'fdir';

const dirname = fileURLToPath(new URL('.', import.meta.url));
caugner marked this conversation as resolved.
Show resolved Hide resolved

class DuplicateCompatError extends Error {
constructor(feature) {
Expand All @@ -27,7 +29,7 @@ function load(...dirs) {
const paths = new fdir()
.withBasePath()
.filter((fp) => fp.endsWith('.json'))
.crawl(path.join(__dirname, dir))
.crawl(path.join(dirname, dir))
.sync();

for (const fp of paths) {
Expand Down Expand Up @@ -67,7 +69,7 @@ function extend(target, source, feature = '') {
}
}

module.exports = load(
export default load(
'api',
'browsers',
'css',
Expand Down
Loading