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 webpack config file, tell webpack about mjs files #1

Merged
merged 2 commits into from
Feb 25, 2019

Conversation

micahstubbs
Copy link
Contributor

@micahstubbs micahstubbs commented Feb 25, 2019

this PR will fix the webpack error about .mjs JavaScript modules files. 😄

short story: it looks like we cannot consume javascript modules (.mjs) files in webpack 4 without telling webpack how to parse those files. the solution that I suggest adds a webpack.config.js file that tells webpack how to parse the .mjs file that d3-circular-sankey ships.

an example to demonstrate a client-code fix for tomshanley/d3-sankey-circular#32

@micahstubbs
Copy link
Contributor Author

@micahstubbs
Copy link
Contributor Author

  1. I read the top 2 search results, and picked the top rated comments.

screen shot 2019-02-24 at 6 51 33 pm

apollographql/apollo-link-state#302 (comment)

and
screen shot 2019-02-24 at 6 51 40 pm

graphql/graphql-js#1272 (comment)

@micahstubbs
Copy link
Contributor Author

  1. I realized that I need to generalize from a Vue framework config file wrapped a webpack config in that first comment that to just a plain webpack config, so I went and read the webpack 4 docs https://webpack.js.org/configuration/

@micahstubbs
Copy link
Contributor Author

  1. then I tried the resulting webpack config with this demo project, and et voila, it worked 🎉

screen shot 2019-02-24 at 6 54 34 pm

build text ➜ d3-sankey-circular-test git:(micah/exp/fix-import) ✗ npm run build

[email protected] build /Users/m/workspace/d3-sankey-circular-test
webpack

Hash: 4aa38395611a79ec6eed
Version: webpack 4.29.5
Time: 295ms
Built at: 02/24/2019 6:46:56 PM
Asset Size Chunks Chunk Names
main.js 59.2 KiB 0 [emitted] main
Entrypoint main = main.js
[5] ./src/index.js + 1 modules 55.4 KiB {0} [built]
| ./src/index.js 67 bytes [built]
| + 1 hidden module
[6] ./node_modules/d3-path/src/index.js + 1 modules 4.12 KiB {0} [built]
| 2 modules
+ 5 hidden modules

@tomshanley
Copy link

Micah - you're a star. thanks for making this update. I tried reading this article but got lost some where in it https://medium.com/passpill-project/files-with-mjs-extension-for-javascript-modules-ced195d7c84a

@peteruithoven peteruithoven merged commit 7bb2be0 into peteruithoven:master Feb 25, 2019
@micahstubbs micahstubbs deleted the micah/exp/fix-import branch February 28, 2019 18:44
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