Skip to content

Commit

Permalink
Fix Node.js ESM module resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
lehni committed Jul 25, 2023
1 parent 16b7425 commit 3b2ce18
Show file tree
Hide file tree
Showing 25 changed files with 77 additions and 76 deletions.
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import type {
} from 'prettier';
import type { Token } from 'pug-lexer';
import lex from 'pug-lexer';
import { logger } from './logger';
import type { PugParserOptions } from './options';
import { options as pugOptions } from './options';
import { convergeOptions } from './options/converge';
import type { PugPrinterOptions } from './printer';
import { PugPrinter } from './printer';
import { logger } from './logger.js';
import { convergeOptions } from './options/converge.js';
import type { PugParserOptions } from './options/index.js';
import { options as pugOptions } from './options/index.js';
import type { PugPrinterOptions } from './printer.js';
import { PugPrinter } from './printer.js';

/** Ast path stack entry. */
interface AstPathStackEntry {
Expand Down Expand Up @@ -127,4 +127,4 @@ export const options: SupportOptions | undefined = plugin.options;
export const defaultOptions: Partial<RequiredOptions> | undefined =
plugin.defaultOptions;

export { ILogger, LogLevel, Logger, createLogger, logger } from './logger';
export { ILogger, LogLevel, Logger, createLogger, logger } from './logger.js';
2 changes: 1 addition & 1 deletion src/options/attribute-sorting/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChoiceSupportOption, PathArraySupportOption } from 'prettier';
import { CATEGORY_PUG } from '../constants';
import { CATEGORY_PUG } from '../constants.js';

const pugSortAttributesOption: PathArraySupportOption = {
// since: '1.7.0',
Expand Down
2 changes: 1 addition & 1 deletion src/options/attribute-sorting/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AttributeToken } from 'pug-lexer';
import type { PugSortAttributes } from './index';
import type { PugSortAttributes } from './index.js';

/** Compare result. */
type CompareResult = -1 | 0 | 1;
Expand Down
2 changes: 1 addition & 1 deletion src/options/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChoiceSupportOption, IntSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Pug print width option. */
export const PUG_PRINT_WIDTH_OPTION: IntSupportOption = {
Expand Down
4 changes: 2 additions & 2 deletions src/options/converge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ParserOptions } from 'prettier';
import type { PugPrinterOptions } from '../printer';
import type { PugParserOptions } from './types';
import type { PugPrinterOptions } from '../printer.js';
import type { PugParserOptions } from './types.js';

/**
* Convert and merge options from Prettier and `pug`-specific options into one option object with normalized default values.
Expand Down
6 changes: 3 additions & 3 deletions src/options/empty-attributes/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ChoiceSupportOption, PathArraySupportOption } from 'prettier';
import { CATEGORY_PUG } from '../constants';
import type { PugEmptyAttributes } from './types';
import { CATEGORY_PUG } from '../constants.js';
import type { PugEmptyAttributes } from './types.js';

/** Pug empty attributes option. */
export const PUG_EMPTY_ATTRIBUTES_OPTION: ChoiceSupportOption<PugEmptyAttributes> =
Expand Down Expand Up @@ -43,4 +43,4 @@ export const PUG_EMPTY_ATTRIBUTES_FORCE_QUOTES_OPTION: PathArraySupportOption =
export type {
PugEmptyAttributes,
PugEmptyAttributesForceQuotes,
} from './types';
} from './types.js';
2 changes: 1 addition & 1 deletion src/options/empty-attributes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { AttributeToken } from 'pug-lexer';
import type {
PugEmptyAttributes,
PugEmptyAttributesForceQuotes,
} from './types';
} from './types.js';

const EMPTY_VALUES: [boolean, string, string] = [true, '""', "''"];

Expand Down
30 changes: 15 additions & 15 deletions src/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PUG_SORT_ATTRIBUTES_BEGINNING_OPTION,
PUG_SORT_ATTRIBUTES_END_OPTION,
PUG_SORT_ATTRIBUTES_OPTION,
} from './attribute-sorting';
} from './attribute-sorting/index.js';
import {
PUG_ARROW_PARENS_OPTION,
PUG_BRACKET_SAME_LINE_OPTION,
Expand All @@ -13,24 +13,24 @@ import {
PUG_SINGLE_QUOTE_OPTION,
PUG_TAB_WIDTH_OPTION,
PUG_USE_TABS_OPTION,
} from './common';
} from './common.js';
import {
PUG_EMPTY_ATTRIBUTES_FORCE_QUOTES_OPTION,
PUG_EMPTY_ATTRIBUTES_OPTION,
} from './empty-attributes';
import { PUG_ATTRIBUTE_SEPARATOR_OPTION } from './pug-attribute-separator';
import { PUG_CLASS_LOCATION } from './pug-class-location';
import { PUG_CLASS_NOTATION } from './pug-class-notation';
import { PUG_COMMENT_PRESERVE_SPACES_OPTION } from './pug-comment-preserve-spaces';
import { PUG_EXPLICIT_DIV } from './pug-explicit-div';
import { PUG_FRAMEWORK } from './pug-framework';
import { PUG_ID_NOTATION } from './pug-id-notation';
import { PUG_PRESERVE_ATTRIBUTE_BRACKETS } from './pug-preserve-attribute-brackets';
import { PUG_SINGLE_FILE_COMPONENT_INDENTATION } from './pug-single-file-component-indentation';
} from './empty-attributes/index.js';
import { PUG_ATTRIBUTE_SEPARATOR_OPTION } from './pug-attribute-separator.js';
import { PUG_CLASS_LOCATION } from './pug-class-location.js';
import { PUG_CLASS_NOTATION } from './pug-class-notation.js';
import { PUG_COMMENT_PRESERVE_SPACES_OPTION } from './pug-comment-preserve-spaces.js';
import { PUG_EXPLICIT_DIV } from './pug-explicit-div.js';
import { PUG_FRAMEWORK } from './pug-framework.js';
import { PUG_ID_NOTATION } from './pug-id-notation.js';
import { PUG_PRESERVE_ATTRIBUTE_BRACKETS } from './pug-preserve-attribute-brackets.js';
import { PUG_SINGLE_FILE_COMPONENT_INDENTATION } from './pug-single-file-component-indentation.js';
import {
PUG_WRAP_ATTRIBUTES_PATTERN,
PUG_WRAP_ATTRIBUTES_THRESHOLD,
} from './pug-wrap-attributes';
} from './pug-wrap-attributes.js';

/**
* All supported options by `@prettier/plugin-pug`.
Expand Down Expand Up @@ -62,5 +62,5 @@ export const options: SupportOptions = {
pugPreserveAttributeBrackets: PUG_PRESERVE_ATTRIBUTE_BRACKETS,
};

export { CATEGORY_PUG } from './constants';
export type { PugParserOptions } from './types';
export { CATEGORY_PUG } from './constants.js';
export type { PugParserOptions } from './types.js';
2 changes: 1 addition & 1 deletion src/options/pug-attribute-separator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChoiceSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Pug attribute separator option. */
export const PUG_ATTRIBUTE_SEPARATOR_OPTION: ChoiceSupportOption<PugAttributeSeparator> =
Expand Down
2 changes: 1 addition & 1 deletion src/options/pug-class-location.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChoiceSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Pug class location. */
export const PUG_CLASS_LOCATION: ChoiceSupportOption = {
Expand Down
2 changes: 1 addition & 1 deletion src/options/pug-class-notation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChoiceSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Pug class notation. */
export const PUG_CLASS_NOTATION: ChoiceSupportOption = {
Expand Down
2 changes: 1 addition & 1 deletion src/options/pug-comment-preserve-spaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChoiceSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Pug comment preserve spaces option. */
export const PUG_COMMENT_PRESERVE_SPACES_OPTION: ChoiceSupportOption<PugCommentPreserveSpaces> =
Expand Down
2 changes: 1 addition & 1 deletion src/options/pug-explicit-div.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BooleanSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Pug default div tag. */
export const PUG_EXPLICIT_DIV: BooleanSupportOption = {
Expand Down
2 changes: 1 addition & 1 deletion src/options/pug-framework.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChoiceSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Pug Framework. */
export const PUG_FRAMEWORK: ChoiceSupportOption<PugFramework> = {
Expand Down
2 changes: 1 addition & 1 deletion src/options/pug-id-notation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChoiceSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Pug id notation. */
export const PUG_ID_NOTATION: ChoiceSupportOption = {
Expand Down
2 changes: 1 addition & 1 deletion src/options/pug-preserve-attribute-brackets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BooleanSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Pug preserve attribute brackets. */
export const PUG_PRESERVE_ATTRIBUTE_BRACKETS: BooleanSupportOption = {
Expand Down
2 changes: 1 addition & 1 deletion src/options/pug-single-file-component-indentation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BooleanSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Pug single file component indentation. */
export const PUG_SINGLE_FILE_COMPONENT_INDENTATION: BooleanSupportOption = {
Expand Down
2 changes: 1 addition & 1 deletion src/options/pug-wrap-attributes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IntSupportOption, PathSupportOption } from 'prettier';
import { CATEGORY_PUG } from './constants';
import { CATEGORY_PUG } from './constants.js';

/** Wrap attributes threshold. */
export const PUG_WRAP_ATTRIBUTES_THRESHOLD: IntSupportOption = {
Expand Down
18 changes: 9 additions & 9 deletions src/options/types.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { ParserOptions } from 'prettier';
import type { PugSortAttributes } from './attribute-sorting';
import type { ArrowParens } from './common';
import type { PugSortAttributes } from './attribute-sorting/index.js';
import type { ArrowParens } from './common.js';
import type {
PugEmptyAttributes,
PugEmptyAttributesForceQuotes,
} from './empty-attributes';
import type { PugAttributeSeparator } from './pug-attribute-separator';
import type { PugClassLocation } from './pug-class-location';
import type { PugClassNotation } from './pug-class-notation';
import type { PugCommentPreserveSpaces } from './pug-comment-preserve-spaces';
import type { PugFramework } from './pug-framework';
import type { PugIdNotation } from './pug-id-notation';
} from './empty-attributes/index.js';
import type { PugAttributeSeparator } from './pug-attribute-separator.js';
import type { PugClassLocation } from './pug-class-location.js';
import type { PugClassNotation } from './pug-class-notation.js';
import type { PugCommentPreserveSpaces } from './pug-comment-preserve-spaces.js';
import type { PugFramework } from './pug-framework.js';
import type { PugIdNotation } from './pug-id-notation.js';

/**
* Extended pug option object.
Expand Down
2 changes: 1 addition & 1 deletion src/prettier.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'prettier';
import type { PugParserOptions } from './options';
import type { PugParserOptions } from './options/index.js';

declare module 'prettier' {
// eslint-disable-next-line jsdoc/require-jsdoc
Expand Down
42 changes: 21 additions & 21 deletions src/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,34 @@ import type {
WhileToken,
YieldToken,
} from 'pug-lexer';
import type { DoctypeShortcut } from './doctype-shortcut-registry';
import { DOCTYPE_SHORTCUT_REGISTRY } from './doctype-shortcut-registry';
import { logger } from './logger';
import type { PugSortAttributes } from './options/attribute-sorting';
import type { DoctypeShortcut } from './doctype-shortcut-registry.js';
import { DOCTYPE_SHORTCUT_REGISTRY } from './doctype-shortcut-registry.js';
import { logger } from './logger.js';
import type { PugSortAttributes } from './options/attribute-sorting/index.js';
import {
compareAttributeToken,
partialSort,
} from './options/attribute-sorting/utils';
import type { ArrowParens } from './options/common';
} from './options/attribute-sorting/utils.js';
import type { ArrowParens } from './options/common.js';
import type {
PugEmptyAttributes,
PugEmptyAttributesForceQuotes,
} from './options/empty-attributes';
import { formatEmptyAttribute } from './options/empty-attributes/utils';
import type { PugAttributeSeparator } from './options/pug-attribute-separator';
import { resolvePugAttributeSeparatorOption } from './options/pug-attribute-separator';
import type { PugClassLocation } from './options/pug-class-location';
import type { PugClassNotation } from './options/pug-class-notation';
import type { PugCommentPreserveSpaces } from './options/pug-comment-preserve-spaces';
import { formatPugCommentPreserveSpaces } from './options/pug-comment-preserve-spaces';
import type { PugFramework } from './options/pug-framework';
import type { PugIdNotation } from './options/pug-id-notation';
} from './options/empty-attributes/index.js';
import { formatEmptyAttribute } from './options/empty-attributes/utils.js';
import type { PugAttributeSeparator } from './options/pug-attribute-separator.js';
import { resolvePugAttributeSeparatorOption } from './options/pug-attribute-separator.js';
import type { PugClassLocation } from './options/pug-class-location.js';
import type { PugClassNotation } from './options/pug-class-notation.js';
import type { PugCommentPreserveSpaces } from './options/pug-comment-preserve-spaces.js';
import { formatPugCommentPreserveSpaces } from './options/pug-comment-preserve-spaces.js';
import type { PugFramework } from './options/pug-framework.js';
import type { PugIdNotation } from './options/pug-id-notation.js';
import {
isAngularAction,
isAngularBinding,
isAngularDirective,
isAngularInterpolation,
} from './utils/angular';
} from './utils/angular.js';
import {
detectDangerousQuoteCombination,
detectFramework,
Expand All @@ -94,17 +94,17 @@ import {
previousTagToken,
previousTypeAttributeToken,
unwrapLineFeeds,
} from './utils/common';
import { getScriptParserName } from './utils/script-mime-types';
import { isSvelteInterpolation } from './utils/svelte';
} from './utils/common.js';
import { getScriptParserName } from './utils/script-mime-types.js';
import { isSvelteInterpolation } from './utils/svelte.js';
import {
isVueEventBinding,
isVueExpression,
isVueVBindExpression,
isVueVDirective,
isVueVForWithOf,
isVueVOnExpression,
} from './utils/vue';
} from './utils/vue.js';

/**
* Options for `@prettier/plugin-pug`.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/angular.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isQuoted, isWrappedWith } from './common';
import { isQuoted, isWrappedWith } from './common.js';

/**
* Indicates whether the attribute name is an Angular binding.
Expand Down
4 changes: 2 additions & 2 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AttributeToken, TagToken, Token } from 'pug-lexer';
import type { Logger } from '../logger';
import type { PugFramework } from '../options/pug-framework';
import type { Logger } from '../logger.js';
import type { PugFramework } from '../options/pug-framework.js';

/**
* Returns the previous tag token if there was one.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/svelte.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isQuoted, isWrappedWith } from './common';
import { isQuoted, isWrappedWith } from './common.js';

/**
* Indicates whether the attribute value is a Svelte interpolation.
Expand Down
1 change: 1 addition & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ES2022",
"moduleResolution": "NodeNext",
"noEmit": false,
"inlineSourceMap": true,
"rootDir": "src",
Expand Down

0 comments on commit 3b2ce18

Please sign in to comment.