-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix(requirejs): temporary fix for build #5
fix(requirejs): temporary fix for build #5
Conversation
this temp fix is for until we figure out what is causing gulp to lookup the index.js in the respective dependencies root-folder vs dist/commonjs
@ghiscoding I've created this PR on top of your PR in the slickgrid-demos repo due to access restrictions. It's related to the quick-fix mentioned in ghiscoding/aurelia-slickgrid#466 |
Thanks, I added you as a collaborator here as well, that's probably why you couldn't push directly. |
That's strange, I know the commonjs entry works because I use within the Slickgrid-Universal monorepo when it builds and when it uses the {
"name": "@slickgrid-universal/common",
"version": "0.5.1",
"description": "SlickGrid-Universal Common Code",
"browser": "src/index.ts",
"main": "dist/commonjs/index.js",
"module": "dist/es2015/index.js",
"typings": "dist/commonjs/index.d.ts",
"type": "module",
"author": "Ghislain B.",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"files": [
"/dist"
]
} Do you see anything wrong with it? I guess you could try to modify the |
I wonder if @3cp can help understand what the problem might be? To give you a bit of a background, I'm switching Aurelia-Slickgrid to use a common code monorepo structure called Slickgrid-Universal and I believe the |
I think all is fine from the package json as the main points to the proper file. I havent yet debugged into how dependencies are requested by the underlying gulp build Task, perhaps there is just a simple thing left. But @3cp definitely can add more insights faster. I'll be able to tackle this on Monday. The leading slash might be such an indicator |
I will have a look tomorrow. |
I checked |
Bundlers (webpack and also cli-bundler) by default use "browser", "module", "main" fields in package.json in that order. In this case, "browser" field is picked up. |
Ahh very good catch. Not even sure if its a worthy improvement to the CLI but perhaps a good doc. I'll try to document the order somewhere suiting in the CLI docs |
hmm good catch but I can't really change the I think it works as I expect it to work on my side because I have this WebPack config in which Prod will default to resolve: {
mainFields: production ? ['module', 'main'] : ['browser', 'module', 'main']
} Are there other alternatives to fix this? I don't want to lose my VSCode debugger in Slickgrid-Universal |
But isn't the bundler (RequireJS) suppose to go to the next available entry point, which is |
Yes, I can and should improve cli-bundler to fall back gracefully. On the other side, I don't know much about vscode debugger, but hijacking "browser" field seems to be weird solution. |
That's unfortunately the best I could find to get the debugger working with direct access to the source file, I couldn't get it working properly from the sourcemap. That indeed would be great if the CLI bundler could fall back gracefully from |
Running into trouble for aurelia-cli because of the existing coupled code structure. It was an easy fix for dumber bundler. |
Another relatively easy option for you would be to create two custom scripts for "prepublish" and "postpublish".
|
Yeah I actually had that in mind, I was hoping that you could fix the CLI but if it's too much work (or not possible) then I'll look at modifying the package.json. I'm not using Gulp though but it should be doable with plain NodeJS code. Thanks for looking into this @3cp. |
I haven't put more effort into cli fix. It requires some level of refactoring. If you can patch the package.json for publishing, pls do it. Previously I had small motivation to enhance dumber core functionality so cli can reuse it and remove the outdated cli bundler code. That would solve more cli bundler known issues which were fixed by dumber design. But I never made the decision to pursue the enhancement because of the work load and the status of the going-to-be outdated aurelia 1 cli. |
@ghiscoding perhaps you can open a new issue describing how you're doing the Debugging including vscode settings file. Then we could try to fix the core issue instead. As @3cp mentioned it really doesn't make a lot of sense to fix the CLI as its going to be obsolete with V2 and most users anyway go with Webpack. Plus there is this workaround merged and a documentation might be enough |
@zewa666 @3cp {
"new-version": "lerna version --conventional-commits",
"prepublishOnly": "lerna run package:remove-browser-prop",
"publish": "lerna publish from-package --registry=https://registry.npmjs.org/",
"postpublish": "lerna run package:add-browser-prop"
} and you can see that BUT, that still doesn't fix the RequireJS build... I just don't understand, if I look at unpkg it's all good now, why isn't that working then? What I mean is that if I remove the Slickgrid-Universal dependency mappings (with this commit) that @zewa666 added in the You guys can test it out with this PR and to get RequireJS to work, then rollback this commit It shows auto-tracing in the command line without any errors though INFO [Bundler] Auto tracing package: 0.7.7 @slickgrid-universal/common Actually Could it be because I'm re-exporting everything with |
Note for npm package started with name |
|
Sorry, the |
But why is it trying to use the to give a bit of a background, SlickGrid is an old jQuery lib, and |
From the two screenshots, you can see CellExternalCopyManager is not the only thing missing in Slick when using es2015 dist files. |
oh I see it in your print screen, that is actually the How did you get these kind of print screen? That is very helpful to look at it that way, is that an OS or an editor thing? |
It was the standard screenshot tool provided by macOS. |
What would happen if I remove the |
It looks like your dynamic required plugins are those missing ones. :-) |
Yes, you can remove module for an easy fix. You just lose the tree-shaking in webpack which only works on esm. |
Yes indeed, I have been considering for some time to refactor that, so that is an even more of a push to do it. Thanks for everything, this is really, really helpful. Can't say it enough 😉 |
esm is the EcmaScript Module format. You can setup tsc to emit esm code and still target older browser (didn't support 2015 syntax). For example, aurelia 1 core modules have |
You are welcome. |
@3cp
So the end result is that I managed to get rid of all the mappings that were previously necessary and now most of the packages are auto-detected by the CLI. We're back to business 😉 I wanted to thank you again for all the time you spent in helping me achieve better support with better ESM builds as well Cheers and happy year end. 🎄 |
Sounds great! Same thanks for you too, as you too are doing open source to help others. |
this temp fix is for until we figure out what is causing gulp to lookup the index.js in the respective dependencies root-folder vs dist/commonjs