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

consider switching to esm format needs thinking about #53

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
File renamed without changes.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 2.0.0

Support for ESM and CommonJS for NodeJS ecosystem

BREAKING CHANGE: To package exports.

- "main" field points to CommonJS version of the library
- "type" changed to module for ESM.
- Exports entries added

# Plugin imports breaking change
- Imports for plugins such as webdriver.io must be done like so:
`require("query-selector-shadow-dom/plugins/webdriverio")` with `index.js`.
19 changes: 19 additions & 0 deletions examples/jsdom/cjs/jsdom.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const jsdom = require("jsdom");
const querySelectorShadowDom = require("../../dist/querySelectorShadowDom.cjs");
const { JSDOM } = jsdom;

const dom = new JSDOM(`<!DOCTYPE html><div class="shadowRoot">Parent</div>`);
const shadowRoot = dom.window.document.querySelector(".shadowRoot");

const root = shadowRoot.attachShadow({
mode: "open"
});

root.innerHTML = `<p>Hello Matt</p>`;
// test frameworks normally do this, i think
global.document = dom.window.document;
global.Node = dom.window.Node;
console.log(querySelectorShadowDom.querySelectorDeep("p", dom.window.document).textContent);



12 changes: 12 additions & 0 deletions examples/jsdom/cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "cjs",
"version": "1.0.0",
"description": "This is just here to let me do common js dev",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
21 changes: 21 additions & 0 deletions examples/jsdom/jsdom.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// TIP: to make ESM work in NodeJS either use .mjs extension or set "type": "module"
// in package.json
import jsdom from "jsdom";
import {querySelectorDeep} from "query-selector-shadow-dom";
const { JSDOM } = jsdom;

const dom = new JSDOM(`<!DOCTYPE html><div class="shadowRoot">Parent</div>`);
const shadowRoot = dom.window.document.querySelector(".shadowRoot");

const root = shadowRoot.attachShadow({
mode: "open"
});

root.innerHTML = `<p>Hello Matt</p>`;
// test frameworks normally do this, i think
global.document = dom.window.document;
global.Node = dom.window.Node;
console.log(querySelectorDeep("p", dom.window.document).textContent);



Loading