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

jsonlint breaks angular apps, replace it. #844

Closed
raysuelzer opened this issue Dec 5, 2018 · 10 comments
Closed

jsonlint breaks angular apps, replace it. #844

raysuelzer opened this issue Dec 5, 2018 · 10 comments

Comments

@raysuelzer
Copy link

mapbox-gl-js version: 0.51.0
mapbox-gl-draw version: ^1.1.1

Steps to Trigger Behavior

  1. import * as MapboxDraw from '@mapbox/mapbox-gl-draw';
  2. ng build

Expected Behavior

Webpack / Angular should be able to build package

Actual Behavior

WARNING in ./node_modules/jsonlint-lines/lib/jsonlint.js
684:16-23 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

ERROR in ./node_modules/jsonlint-lines/lib/jsonlint.js
Module not found: Error: Can't resolve 'fs' in 'C:\an\interact-frontend\node_modules\jsonlint-lines\lib'
ERROR in ./node_modules/jsonlint-lines/lib/jsonlint.js
Module not found: Error: Can't resolve 'path' in 'C:\an\interact-frontend\node_modules\jsonlint-lines\lib'

Please remove the dependecy on jsonlint, it is no longer supported or maintained and will not work for people using angular-cli. We do not have an option to specify node property since webpack.config is abstracted.

@hallo02
Copy link

hallo02 commented Apr 2, 2019

Is there a workaround?

@The-End-Hero
Copy link

I have encountered the same problem

@ghost
Copy link

ghost commented Apr 19, 2019

I was in the same situation. This worked for me:

import * as MapboxDraw from '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw';

@laurenoldham1202
Copy link

laurenoldham1202 commented Apr 19, 2019

Up until yesterday, I was able to use the workaround detailed here in which you add this bit of code to your package.json file (at the same level as name, version, scripts, etc.):
"browser": { "fs": false, "path": false, "os": false },

Worked up until I did a git rebase on my code today. The above solution import * as MapboxDraw from '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw'; worked for me! +1

@silberjan
Copy link

Using a deep import like '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw'; is not really a solution. (see microsoft/TypeScript#20160 (comment))

Ivy starts to complain about them already. It would be way better to either fork jsonlint-lines or use something else

@vinayakkulkarni
Copy link

Facing a similar issue in the Nuxt based Vue App

+ import * as MapboxDraw from '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw';
- import * as MapboxDraw from '@mapbox/mapbox-gl-draw';

This hack works successfully though.

@kkaefer
Copy link
Contributor

kkaefer commented Jan 7, 2020

You should use the packaged version in the dist folder to avoid bundling errors as @vinayakkulkarni pointed out. For those curious, we're excluding the path and fs modules from being bundled. The geojsonlint module only uses them in the main function which we never call, so it's eliminated from the final build anyway.

@kkaefer kkaefer closed this as completed Jan 7, 2020
@trygveaa
Copy link

@kkaefer: If we should use the version from the dist directory, why do you set main: "index.js" in package.json?

@deepaksslibra
Copy link

import * as MapboxDraw from '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw'

Stuck on this right now 😆

@yogeshhrathod
Copy link

import * as MapboxDraw from '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw'

This is not working as well getting error

./node_modules/@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.js
Module not found: Error: Can't resolve 'fs' in '/home/po/practice/mapbox/mapbox_test_1/node_modules/@mapbox/mapbox-gl-draw/dist'

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

10 participants