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

Only Babel 7 support with @babel/helper-module-imports #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nodkz
Copy link

@nodkz nodkz commented Nov 15, 2017

Do not merge! May break babel 6 support.

Only for demo purposes, who want to migrate to Babel 7 scoped packages under @babel/....

Can be installed in such way:

yarn add https://github.com/nodkz/babel-plugin-import-inspector.git#babel7 --dev

@xusai2014
Copy link

xusai2014 commented May 4, 2018

@nodkz Hello
I use the babel-plugin-import-inspector in babel7.But failed to work. the error info is as below

        return (0, _importInspector.report)(import('../page/Home.jsx'), {
                                            ^^^^^^
SyntaxError: Unexpected token import
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Module._compile (/Users/jerryxu/WebstormProjects/credit-font/node_modules/pirates/lib/index.js:91:24)
    at Module._extensions..js (module.js:580:10)
    at Object.newLoader [as .jsx] (/Users/jerryxu/WebstormProjects/credit-font/node_modules/pirates/lib/index.js:96:7)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/jerryxu/WebstormProjects/credit-font/server/generate.js:8:1)
    at Module._compile (module.js:571:32)
    at Module._compile (/Users/jerryxu/WebstormProjects/credit-font/node_modules/pirates/lib/index.js:91:24)
    at Module._extensions..js (module.js:580:10)
    at Object.newLoader [as .js] (/Users/jerryxu/WebstormProjects/credit-font/node_modules/pirates/lib/index.js:96:7)


I want to do SSR

@nodkz
Copy link
Author

nodkz commented May 4, 2018

It's very strange. Do you use babel-preset-env? Maybe need to set option modules to commonjs.
Try to play with your babelrc config.
Take a look on this config https://github.com/nodkz/react-relay-network-modern/blob/master/.babelrc

PS. Sorry I cannot consult your here more. Please try to solve it yourself. I have not ready solution. Thanks.

@xusai2014
Copy link

@nodkz

{
  "presets": [
    ["@babel/preset-env", {
      "targets": {
        "browsers": ["ie>=8", ">1% in CN", "iOS >= 8", "Android >= 4"]
      }
    }],
    "@babel/preset-react"
  ],
  "plugins": [
    "@babel/plugin-proposal-object-rest-spread",
    "@babel/plugin-syntax-dynamic-import",
    ["@babel/plugin-syntax-decorators",{"legacy":true}],
    ["@babel/plugin-proposal-class-properties"],
    ["@babel/plugin-transform-runtime",{
      "helpers": false,
      "polyfill": false,
      "regenerator": true,
      "useESModules":false,
      "moduleName": "@babel/runtime"
    }],
    ["import", {
      "libraryName": "antd",
      "style": true
    }],
    ["import-inspector", {
      "serverSideRequirePath": true
    }]

  ]
}

this is my .babelrc config file.

@JasonBoy
Copy link

After upgrading to babel7, and remove import-inspector in plugins, only with 'react-loadable/babel', the SSR still works, not sure if this plugin is still needed?

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

Successfully merging this pull request may close these issues.

3 participants