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

Dexie2 with Webpack2 is incompatible with ES5 #466

Closed
dpogue opened this issue Jan 30, 2017 · 9 comments
Closed

Dexie2 with Webpack2 is incompatible with ES5 #466

dpogue opened this issue Jan 30, 2017 · 9 comments

Comments

@dpogue
Copy link
Contributor

dpogue commented Jan 30, 2017

Webpack 2 supports ES6 modules and uses the module field in package.json to look for a module-ized version of the source files. It does not do any transpiling of the files that it finds.

Dexie 2.0.0-beta.9 provides a full ES6 version in its module field, which results in Webpack bundling files that aren't compatible with ES5 browsers. The TypeScript .d.ts also requires full ES6 support enabled due to Iterables and Symbol.toStringTag.

This effectively means we have to choose between Webpack 2 and Dexie 2, or figure out how to blacklist loading Dexie with ES6 modules in our Webpack config.

I'm not sure what the best solution here is... Webpack and Rollup's guidelines are to publish and point to ES5-compatible code using only the ES6 module syntax in the module field.

@dfahlander
Copy link
Collaborator

This is mostly a duplicate of #460. The typings issue is fixed using:

"lib": ["dom", "es2015"]

in tsconfig.json. Dexie does not depend on any runtime es6 feature but used some when available (such as toStringTag, Symbol and Iterators)

@dpogue
Copy link
Contributor Author

dpogue commented Jan 30, 2017

It looked like Dexie was using const which was causing errors in PhantomJS.

@dfahlander
Copy link
Collaborator

Next release will have #460 fixed so there will be no const in the dist version. If it's a showstopper we could release it asap.

@dpogue
Copy link
Contributor Author

dpogue commented Jan 31, 2017

No rush, was just testing out the beta :)

@dfahlander
Copy link
Collaborator

Thanks for testing it out 🥇 Resently released beta 10. If you have a change, please try it and see if it resolves the issue. Closing for now, feel free to reopen!

@dpogue
Copy link
Contributor Author

dpogue commented Jan 31, 2017

I can confirm beta 10 works :)

@sebastien-roch
Copy link

I'm having the same issue, the beta 11 does not work for me. Here is my tsconfig:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true,
    "strictNullChecks": true,
    "noImplicitAny": false,
    "outDir": "./dist/",
    "sourceMap": true,
    "target": "es5",
    "module": "commonjs"
  },
  "lib": ["dom", "es2015.promise", "es5"]
}

I get the error: ERROR in \Some\project\node_modules\dexie\dist\dexie.d.ts (134,19): error TS2304: Cannot find name 'Symbol'.

I tried changing lib to ["dom", "es2015"] , that doesn't help.
Using Typescript 2.4.1.

Thanks for your help.

@nponiros
Copy link
Collaborator

@sebastien-roch put "lib": ["dom", "es2015"] into compilerOptions.

@sebastien-roch
Copy link

@nponiros oh my... thanks, that did the trick! (but I'm surprised Typescript didn't catch that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants