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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: 馃悰 use of the package in browsers #94
fix: 馃悰 use of the package in browsers #94
Conversation
@Atinux It would be great :) |
My fear is that there may be people who are pointing to the file as shown in the DOC, if you make this change of file location it can break for people. It is very complicated to move the file.I don't think that would be correct.An alternative would be to change both Or the option is to change the But it is necessary to test for both the NodeJs and the Browser. |
Or perhaps the best option is to change the |
I'm going to need someone with Bower expertise to take a look at this issue. I have no experience at all with Bower and not enough time to learn it right now. If someone can take a look at this and post proof that a particular change fixes Bower imports, I can merge it in. @ViniciusFXavier it looks like you're familiar with Bower and you've already decided on the best course of action. Can you provide a simple explanation for me? I'll need something for release notes anyways. I'll release 2.0.1 with the fix today if we can get it all sorted out. Also, I'm curious... do we know if this is an issue that just came up with 2.0.0 or has this always been an issue? I wasn't around when the library was created many years ago, but since I started having eyes on it in late 2018, I never noticed anyone mention issues using it with Bower. |
Also note that @Atinux is no longer a maintainer of this library. |
Best alternative: #94 (comment)Add this to (function () {
var root = this;
var SchemaInspector = new Object();
if (typeof module !== 'undefined' && module.exports) {
SchemaInspector = require('./lib/schema-inspector');
module.exports = SchemaInspector;
}
root.SchemaInspector = SchemaInspector;
})(); When doing this will not broken. <script type="text/javascript" src="bower_components/schema-inspector/lib/schema-inspector.js"></script> |
@ViniciusFXavier |
Hello @mattwelke, Basically what Bower is doing is what is written in the file <!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<script type="text/javascript" src="https://rawgit.com/caolan/async/master/dist/async.js"></script>
<script type="text/javascript" src="https://rawgit.com/atinux/schema-inspector/master/index.js"></script>
</head>
<body>
<h1>Schema Inspector</h1>
</body>
</html> |
Exactly my fear with the content of this PR to change things to With the suggestion that I gave you will continue to work both previous versions and new ones. More realistically, the content in the |
@ViniciusFXavier Nice, I have a decent understanding of the issue now and what we'll do to fix it. @ottonielmatheus thank you sending in this PR but I don't want to fix it by removing the lib file. I don't want people who've followed the readme to install it with Bower to have their setups break (if they were working at any point in the past). I'm going to go with @ViniciusFXavier 's suggestion to improve how index.js detects browser vs. Node.js and how it imports the lib file, so that index.js will always work in browsers. I'll make the change in a separate PR, add some tests with Puppeteer in the CI/CD to assert that the files are usable by the browser directly, and release the fix as 2.0.1. I'll get this done within the next few days. |
@mattwelke Ok, waiting for fix, thank you guys!! |
@mattwelke I was doing some tests here and I think the best alternative is would be to change both Because in the lines indicated below they already do the same treatment that I gave as an example for the file schema-inspector/lib/schema-inspector.js Lines 1548 to 1553 in e02ea1f
This change would work for both CommonJS, RollupJS and Gulp or any other module bundler for JavaScript, and the previous packages using this will continue to work. |
It looks like 7 years ago, they actually changed Bower to use index.js in order to fix a Bower install issue back then: 2595511 Do we understand why they would have done that and why we now need to do this in reverse to fix it again? |
Exactly I saw it too, I just don't understand why they did it. This PR change to the index #11 Lib has not worked properly in browsers for 7 years, you can go back to the version and test. 馃槥 The same error will be displayed on the debugger console. |
I see. Interesting that no one has mentioned this issue in 7 years. I have to admit, I was surprised to see an issue today claiming that the library doesn't work in browsers. We've used it in browsers at my work in production for 4 years. Our workflow is to bundle it in with Webpack. When used in browsers that way, it works perfectly. I think in 2021, we should actually consider whether Bower support is something we should continue to support going forward. My understanding is that it's an outdated way to build JS applications for browsers. Is this correct? The example web page already successfully loads the JS file by linking to it with a |
Accidental closing |
Yeah if I recall, Webpack can follow the I don't like the idea of making changes I perceive as dangerous (like editing @ottonielmatheus I plan to drop support for Bower in the 3.0.0 release that I'll be publishing later this year. Would the workaround you've found satisfy you for now instead of changing the way code is laid out in the repo to allow Bower builds according to the current Bower instructions in the README? I can add the workaround instructions to the README or merge in this PR if it were changed to just be a README update explaining the workaround. |
This is exactly what I'm proposing. |
As a reminder of where we're at right now, we need a PR that involves no changes to how the code is structured and adds instructions to the readme explaining how Bower users can use the library in its current state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consensus is to use workaround instead of changing code. Please change PR to only add workaround instructions to README.md
closes: #93
An export problem that occurs when using the package by
bower
in the browser makes it useless to use it in browsers.There is a validation to identify whether the environment is
server-side
orclient-side
in the file, but before this file is exported, it tries to usemodule.exports
andrequire
, as it does not have validation in theindex.js
file, at a time, it breaks and makes it impossible to use the package in the browser.The fix is simple, but it changes structure, it is necessary that
index.js
be the old filelib/schema-inspector.js
.