ember-fastboot / ember-fastboot/simple-dom
Unable to import simple-dom with typescript and webpack
- Dominant language
- TypeScript
- Stars
- 207
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to get simpledom working in codebase with two environments. One with `ts-node` and another with `webpack` and `ts-loader` with `"esModuleInterop": true,`
With `simple-dom@1.3.0` I could do
```ts
import { Document, HTMLSerializer } from 'simple-dom'
```
And it worked in all environments but has a bug where I had to include `dom` in my tsconfig `libs` configuration to get typescript to compile.
For the upgrade to `1.4.0`, the previous code works with `ts-node` but webpack changes the export from `simple-dom` to be a single export named `simple-dom`
This works but only in webpack with `ts-loader@5.3.3` and not with `ts-node`
```ts
const {
simpleDom: { Document, HTMLSerializer },
} = require('simple-dom')
```
The following work with nothing... errors are from webpack.
```ts
import simpleDom from 'simple-dom'
console.log({ simpleDom })
// { simpleDom: undefined }
```
```ts
import { simpleDom } from 'simple-dom'
console.log({ simpleDom })
// { simpleDom: undefined }
```
```ts
import simpledom from 'simple-dom/dist/modules/es2017'
console.log({ simpledom })
// { simpledom: undefined }
```
```ts
import { Document, HTMLSerializer } from 'simple-dom/dist/modules/es2017'
// [2019-02-07T17:44:36.740Z] ERROR (gradius): a.HTMLSerializer is not a constructor
// TypeError: a.HTMLSerializer is not a constructor
// at Object. (/Users/wizard/src/gradius/dist/webpack-test/index.js:1493:696)
```
I'm not sure where to go from here. Any ideas?
Thanks!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.