Skip to content

Commit bb2ab42

Browse files
committed
use esm properly with node
1 parent 4f8dabb commit bb2ab42

11 files changed

+552
-1096
lines changed

generate-local.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import chalk from 'chalk';
22
import commandExists from 'command-exists';
33
import execa from 'execa';
4-
import { copyFileSync, ensureFileSync, existsSync, removeSync } from 'fs-extra';
4+
import fsExtra from 'fs-extra';
55
import minimist from 'minimist';
66
import path from 'path';
77

8+
const { copyFileSync, ensureFileSync, existsSync, removeSync } = fsExtra;
9+
810
const docsPath = '../ember-api-docs-data';
911

1012
const argv = minimist(process.argv.slice(2));
@@ -47,8 +49,8 @@ async function runCmd(cmd, path, args = []) {
4749
exit(chalk.red('We need yarn installed globally for this script to work'));
4850
}
4951

50-
let emberProjectPath = path.join(__dirname, '../', 'ember.js');
51-
let emberDataProjectPath = path.join(__dirname, '../', 'data');
52+
let emberProjectPath = path.join('../', 'ember.js');
53+
let emberDataProjectPath = path.join('../', 'data');
5254

5355
let checkIfProjectDirExists = dirPath => {
5456
if (!existsSync(dirPath)) {

index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// eslint-disable-next-line
2-
require = require('esm')(module /*, options*/)
1+
import minimist from 'minimist';
2+
import { apiDocsProcessor } from './main.js';
33

4-
const argv = require('minimist')(process.argv.slice(2));
4+
const argv = minimist(process.argv.slice(2));
55

66
let possibleProjects = ['ember', 'ember-data'];
77
let projects =
@@ -11,5 +11,4 @@ let specificDocsVersion = argv.version ? argv.version : '';
1111
let runClean = !!argv.clean;
1212
let noSync = !argv.sync;
1313

14-
const { apiDocsProcessor } = require('./main.js');
1514
apiDocsProcessor(projects, specificDocsVersion, runClean, noSync);

lib/get-latest-patch-versions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { groupBy } from 'lodash';
1+
import { groupBy } from 'lodash-es';
22
import semverCompare from 'semver-compare';
33
import semverUtils from 'semver-utils';
44

lib/read-docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs-extra';
22
import glob from 'glob';
33
import { dasherize } from 'inflected';
4-
import { get as deepGet } from 'lodash';
4+
import { get as deepGet } from 'lodash-es';
55
import { getLatestPatchVersions } from './get-latest-patch-versions.js';
66

77
const docsPath = '../ember-api-docs-data';

lib/rev-docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ora from 'ora';
33
import { basename as getFileName } from 'path';
44
import { singularize } from 'inflected';
55
import path from 'path';
6-
const glob = require('glob');
6+
import glob from 'glob';
77

88
const docsPath = '../ember-api-docs-data';
99

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import moduleData from 'ember-rfc176-data';
21
import keyfinder from 'keyfinder';
3-
import { uniq } from 'lodash';
2+
import { uniq } from 'lodash-es';
3+
import { createRequire } from 'node:module';
4+
import fs from 'fs-extra';
5+
6+
const require = createRequire(import.meta.url);
7+
const moduleDataPath = require.resolve('ember-rfc176-data');
8+
const moduleData = fs.readJsonSync(moduleDataPath);
49

510
export const emberKnownEntityNames = uniq(keyfinder(moduleData, 'export'));

lib/yuidoc-fixer/normalize-yui-doc-class-item.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { toLower } from 'lodash';
1+
import { toLower } from 'lodash-es';
22
import { yuiDocClassItemKeys } from './yui-doc-class-item-keys.js';
33
import { emberKnownEntityNames } from './emberKnownEntityNames.js';
44

lib/yuidoc-fixer/yui-doc-class-item-keys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { without } from 'lodash';
1+
import { without } from 'lodash-es';
22

33
const originalYuiDocClassItemKeys = [
44
'async', // bool, custom events can fire the listeners in a setTimeout

0 commit comments

Comments
 (0)