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

Add require option to documentation in addition to import #6

Closed
lmuzquiz opened this issue Jul 14, 2017 · 2 comments
Closed

Add require option to documentation in addition to import #6

lmuzquiz opened this issue Jul 14, 2017 · 2 comments

Comments

@lmuzquiz
Copy link

lmuzquiz commented Jul 14, 2017

Hello, thanks for this plugin. I don't know why, but with this line on my webpack.config:
import SitemapPlugin from 'sitemap-webpack-plugin';
I got a lot of errors like this:

import SitemapPlugin from 'sitemap-webpack-plugin';
^^^^^^
SyntaxError: Unexpected token import
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at requireConfig 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webpack-starter@1.0.0 dev: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the webpack-starter@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/lmuzquiz/.npm/_logs/2017-07-14T22_23_30_638Z-debug.log

So i had to use the following to make it work:

const SitemapPlugin = require('sitemap-webpack-plugin').default;
Im using webpack 3 and node 8

@lmuzquiz lmuzquiz changed the title Add require option to documentation instead of Add require option to documentation maybe? Jul 14, 2017
@lmuzquiz lmuzquiz changed the title Add require option to documentation maybe? Add require option to documentation in addition to import Jul 14, 2017
@schneidmaster
Copy link
Owner

Hi. Your error is just because import/export are not yet supported in Node.js absent babel (here's some further reading if you're interested in the implementation complexities). You could use babel for your webpack config to support import syntax as is used in the example. I don't really think this is worth separately documenting for this plugin though -- it's dependent on how you write your webpack config (with/without babel) and presumably the end user is already aware of how they're loading modules; and it's an option related to module loading in general, nothing specific to this plugin.

@lmuzquiz
Copy link
Author

all right! thanks for your explanation

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

2 participants