groupon / cson-parser

Simple & safe CSON parser
BSD 3-Clause "New" or "Revised" License
133 stars 27 forks source link

Errors when using with webpack #68

Closed brpaz closed 2 years ago

brpaz commented 6 years ago

Hello. I am trying to use cson-parser in a project using webpack and its not working. Webpack tries to load the binary "coffee"

I am trying to exclude the file from being processed by webpack but still couldnt find a working solution.

WARNING in ./~/coffee-script/lib/coffee-script/coffee-script.js
require.extensions is not supported by webpack. Use a loader instead.
 @ ./~/cson-parser/lib/parse.js 34:12-36
 @ ./~/cson-parser/lib/cson-parser.js
 @ ./src/notesStorage.js
 @ ./src/index.js

WARNING in ./~/coffee-script/lib/coffee-script/coffee-script.js
require.extensions is not supported by webpack. Use a loader instead.
 @ ./~/cson-parser/lib/parse.js 34:12-36
 @ ./~/cson-parser/lib/cson-parser.js
 @ ./src/notesStorage.js
 @ ./src/index.js

WARNING in ./~/coffee-script/lib/coffee-script/coffee-script.js
require.extensions is not supported by webpack. Use a loader instead.
 @ ./~/cson-parser/lib/parse.js 34:12-36
 @ ./~/cson-parser/lib/cson-parser.js
 @ ./src/notesStorage.js
 @ ./src/index.js

WARNING in ./~/coffee-script/lib/coffee-script/register.js
require.extensions is not supported by webpack. Use a loader instead.
 @ ./~/coffee-script/lib/coffee-script/coffee-script.js 243:11-32
 @ ./~/cson-parser/lib/parse.js
 @ ./~/cson-parser/lib/cson-parser.js
 @ ./src/notesStorage.js
 @ ./src/index.js

WARNING in ./~/coffee-script/lib/coffee-script/register.js
require.extensions is not supported by webpack. Use a loader instead.
 @ ./~/coffee-script/lib/coffee-script/coffee-script.js 243:11-32
 @ ./~/cson-parser/lib/parse.js
 @ ./~/cson-parser/lib/cson-parser.js
 @ ./src/notesStorage.js
 @ ./src/index.js

WARNING in ./~/coffee-script/lib/coffee-script/coffee-script.js
214:42-49 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

WARNING in ./~/coffee-script/lib/coffee-script/coffee-script.js
218:26-33 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

ERROR in ./~/coffee-script/bin/coffee
Module parse failed: /media/DATA/Code/personal/cerebro-plugin-boostnote/node_modules/coffee-script/bin/coffee Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
| #!/usr/bin/env node
|
| var path = require('path');
 @ ./~/coffee-script/lib/coffee-script/register.js 52:13-48
 @ ./~/coffee-script/lib/coffee-script/coffee-script.js
 @ ./~/cson-parser/lib/parse.js
 @ ./~/cson-parser/lib/cson-parser.js
 @ ./src/notesStorage.js
 @ ./src/index.js
jkrems commented 6 years ago

Hey - not sure how to best solve this. It looks like coffee-script 1 at least just doesn't have a version that works in a browser. For formatting CSON I have used require('cson-parser/lib/stringify') in the past (which is a hack) but I'm not sure there's an official way to do the same for parsing as well.

This might be solved by upgrading cson-parser to coffee-script 2 but since they changed the name of the npm package, that it unlikely to happen anytime soon (it would cause for anybody who has a reference to coffee-script in their dependency tree). :(

jkrems commented 6 years ago

What you could try is to selectively replace some of the code with empty files in your webpack config. But I'm not sure that'd be enough.

gluons commented 6 years ago

I face the same problem.

require('cson-parser/lib/stringify') work in webpack.
But require('cson-parser/lib/parse') not work.

jkrems commented 6 years ago

@gluons Yeah, parse pulls in the coffeescript entry point and that one accesses a lot of APIs that won't work in webpack. We generally do things like parsing on the server so we don't run into it. But PRs making it work are definitely appreciated. :)

brpaz commented 2 years ago

I am in the process on clean up old open issues. Since this is an old issue and I don´t use this project anymore, I will close it.