-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
feat: Add ES6 module export #680
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from "./parse"; | ||
export { default as parse } from "./parse"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't imports have to be updated to include a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically yes in order to get these to work in a browser it needs to have an extension. However both eslink-pluign-node and jest breaks if I change this to have .js extensions. There is a long thread here: Microsoft don't want to convert these paths to js paths on the fly but they seem to support them now however the rest of the tools for linting and testing here doesn't seem to suppot that. There are workaround for this that for example transpile the js files before being pushed to npm. I've seen people having scripts that just regexp replace this in source. It all depends on how much one want it to work with js modules in the browser. Bundlers will look for default file extensions so this is only an issue if you are loading scripts with |
||
export { default as stringify } from "./stringify"; | ||
export * from "./types"; | ||
export { isTraversal, parse } from "./parse"; | ||
export { stringify } from "./stringify"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
export interface Options { | ||
/** | ||
* When false, tag names will not be lowercased. | ||
* @default true | ||
*/ | ||
lowerCaseAttributeNames?: boolean; | ||
/** | ||
* When false, attribute names will not be lowercased. | ||
* @default true | ||
*/ | ||
lowerCaseTags?: boolean; | ||
/** | ||
* When `true`, `xmlMode` implies both `lowerCaseTags` and `lowerCaseAttributeNames` are set to `false`. | ||
* Also, `ignoreCase` on attributes will not be inferred based on HTML rules anymore. | ||
* @default false | ||
*/ | ||
xmlMode?: boolean; | ||
} | ||
|
||
export type Selector = | ||
| PseudoSelector | ||
| PseudoElement | ||
| AttributeSelector | ||
| TagSelector | ||
| UniversalSelector | ||
| Traversal; | ||
|
||
export interface AttributeSelector { | ||
type: "attribute"; | ||
name: string; | ||
action: AttributeAction; | ||
value: string; | ||
ignoreCase: boolean | null; | ||
namespace: string | null; | ||
} | ||
|
||
export type DataType = Selector[][] | null | string; | ||
|
||
export interface PseudoSelector { | ||
type: "pseudo"; | ||
name: string; | ||
data: DataType; | ||
} | ||
|
||
export interface PseudoElement { | ||
type: "pseudo-element"; | ||
name: string; | ||
} | ||
|
||
export interface TagSelector { | ||
type: "tag"; | ||
name: string; | ||
namespace: string | null; | ||
} | ||
|
||
export interface UniversalSelector { | ||
type: "universal"; | ||
namespace: string | null; | ||
} | ||
|
||
export interface Traversal { | ||
type: TraversalType; | ||
} | ||
|
||
export type AttributeAction = | ||
| "any" | ||
| "element" | ||
| "end" | ||
| "equals" | ||
| "exists" | ||
| "hyphen" | ||
| "not" | ||
| "start"; | ||
|
||
export type TraversalType = | ||
| "adjacent" | ||
| "child" | ||
| "descendant" | ||
| "parent" | ||
| "sibling"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"target": "ES2019", | ||
"module": "es2015", | ||
"outDir": "lib/es", | ||
"moduleResolution": "node" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't specify node it will classic if you change module to es2015. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to test the ESM version of the module as well? Eg. if a
__dirname
was missed somewhere — would that be caught?