Skip to content

use esm properly with node #132

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

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 5 additions & 3 deletions generate-local.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import chalk from 'chalk';
import commandExists from 'command-exists';
import execa from 'execa';
import { copyFileSync, ensureFileSync, existsSync, removeSync } from 'fs-extra';
import fsExtra from 'fs-extra';
import minimist from 'minimist';
import path from 'path';

const { copyFileSync, ensureFileSync, existsSync, removeSync } = fsExtra;

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

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

let emberProjectPath = path.join(__dirname, '../', 'ember.js');
let emberDataProjectPath = path.join(__dirname, '../', 'data');
let emberProjectPath = path.join('../', 'ember.js');
let emberDataProjectPath = path.join('../', 'data');

let checkIfProjectDirExists = dirPath => {
if (!existsSync(dirPath)) {
Expand Down
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line
require = require('esm')(module /*, options*/)
import minimist from 'minimist';
import { apiDocsProcessor } from './main.js';

const argv = require('minimist')(process.argv.slice(2));
const argv = minimist(process.argv.slice(2));

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

const { apiDocsProcessor } = require('./main.js');
apiDocsProcessor(projects, specificDocsVersion, runClean, noSync);
2 changes: 1 addition & 1 deletion lib/get-latest-patch-versions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { groupBy } from 'lodash';
import { groupBy } from 'lodash-es';
import semverCompare from 'semver-compare';
import semverUtils from 'semver-utils';

Expand Down
2 changes: 1 addition & 1 deletion lib/read-docs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs-extra';
import glob from 'glob';
import { dasherize } from 'inflected';
import { get as deepGet } from 'lodash';
import { get as deepGet } from 'lodash-es';
import { getLatestPatchVersions } from './get-latest-patch-versions.js';

const docsPath = '../ember-api-docs-data';
Expand Down
2 changes: 1 addition & 1 deletion lib/rev-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ora from 'ora';
import { basename as getFileName } from 'path';
import { singularize } from 'inflected';
import path from 'path';
const glob = require('glob');
import glob from 'glob';

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

Expand Down
9 changes: 7 additions & 2 deletions lib/yuidoc-fixer/emberKnownEntityNames.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import moduleData from 'ember-rfc176-data';
import keyfinder from 'keyfinder';
import { uniq } from 'lodash';
import { uniq } from 'lodash-es';
import { createRequire } from 'node:module';
import fs from 'fs-extra';

const require = createRequire(import.meta.url);
const moduleDataPath = require.resolve('ember-rfc176-data');
const moduleData = fs.readJsonSync(moduleDataPath);

export const emberKnownEntityNames = uniq(keyfinder(moduleData, 'export'));
2 changes: 1 addition & 1 deletion lib/yuidoc-fixer/normalize-yui-doc-class-item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toLower } from 'lodash';
import { toLower } from 'lodash-es';
import { yuiDocClassItemKeys } from './yui-doc-class-item-keys.js';
import { emberKnownEntityNames } from './emberKnownEntityNames.js';

Expand Down
2 changes: 1 addition & 1 deletion lib/yuidoc-fixer/yui-doc-class-item-keys.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { without } from 'lodash';
import { without } from 'lodash-es';

const originalYuiDocClassItemKeys = [
'async', // bool, custom events can fire the listeners in a setTimeout
Expand Down
Loading