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

Browser support #55

Closed
jasonqsong opened this issue Jun 29, 2019 · 2 comments
Closed

Browser support #55

jasonqsong opened this issue Jun 29, 2019 · 2 comments
Labels
🙋 no/question This does not need any changes

Comments

@jasonqsong
Copy link

The dependency "is-plain-obj" npm package is not compatible with ...... IE

tl;dr is-plain-object seems like a good alternative.

Unlike other packages, "is-plain-obj" is publishing arrow functions without transpiling. It will cause the applications that use IE as the javascript engine failing to load unifiedjs. For my case, it's on-premise MS Word 2019. In addition, although "is-plain-obj" is a 4 line function, it's claiming to support node8+ only. I believe unifiedjs is aiming to support both browser and backends, so a backend only package might not be a good dependency.

FYI, my use case is writing a text processor as an Add-on for MS Word with typescript and unified. My current workaround is using babel to load this package first in my webpack.config.js. Which is obviously an anti-pattern because I'm compiling the package in node_modules

      rules: [
        {
          test: /node_modules\/.*is\-plain\-obj.*\.js$/,
          use: {
            loader: "babel-loader",
            options: { presets: ["@babel/preset-env"] },
          },
        },

Your environment

  • OS: Windows 10
  • Packages: unified, webpack
  • Env: IE11

Steps to reproduce

  1. Create a minimal project
#!/bin/bash
mkdir -p minimal-project/src
cd minimal-project
echo '<script src="main.js"></script>' > index.html
echo 'import unified from "unified"' > src/index.js
yarn add unified webpack webpack-cli webpack-dev-server
./node_modules/.bin/webpack-dev-server --mode development
  1. Open Intenet Explorer and navigate to http://localhost:8080

Then see syntax error from is-plain-obj

image

Expected behaviour

unifiedjs should load correctly

Actual behaviour

The 'is-plain-obj' npm package contains ES6 syntax

@ChristianMurphy
Copy link
Member

Unified can be run in the browser, to do so it needs to be bundled (using webpack, rollup, etc) and transpiled (babel, buble, sucrose, etc) (see #34 (comment)).

Transpiling dependencies for IE is something that could be covered in a guide unifiedjs/unifiedjs.github.io#7


Which is obviously an anti-pattern because I'm compiling the package in node_modules

Transpiling dependencies is not an anti pattern.
It is supported by webpack, rollup, create-react-app, and vue-cli because it is a common need, especially when IE support is a requirement.


PRs adding documentation and guides are welcome!

@jasonqsong
Copy link
Author

Sounds good! I just created a super simple guide for it. Wonder if you'd like to accept it :)

@wooorm wooorm changed the title The dependency "is-plane-obj" is not browser friendly Browser support Aug 10, 2019
@wooorm wooorm added the 🙋 no/question This does not need any changes label Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes
3 participants