- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 276
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 browser field to package.json to fix webpack #308
Conversation
This should close slevithan#305, see slevithan#305 (comment): > Actually, after reading https://webpack.js.org/configuration/resolve/#resolvemainfields more closely, it sounds like adding a `browser` field to `package.json`, that points to `lib/index.js` (same as `main`) should fix things. > > > resolve.mainFields > > [string] > > > > When importing from an npm package, e.g. import * as D3 from 'd3', this option will determine which fields in its package.json are checked. The default values will vary based upon the target specified in your webpack configuration. > > > > When the target property is set to webworker, web, or left unspecified: > > > > webpack.config.js > > > > module.exports = { > > //... > > resolve: { > > mainFields: ['browser', 'module', 'main'] > > } > > }; > > For any other target (including node): > > > > webpack.config.js > > > > module.exports = { > > //... > > resolve: { > > mainFields: ['module', 'main'] > > } > > }; > > For example, consider an arbitrary library called upstream with a package.json that contains the following fields: > > > > { > > "browser": "build/upstream.js", > > "module": "index" > > } > > When we import * as Upstream from 'upstream' this will actually resolve to the file in the browser property. The browser property takes precedence because it's the first item in mainFields. Meanwhile, a Node.js application bundled by webpack will first try to resolve using the file in the module field. > > I'll open a PR for that.
Travis CI is no longer providing CI minutes for open source projects: https://news.ycombinator.com/item?id=25338983 It's also been pretty slow: the build for slevithan#308 hasn't started in 13 minutes
Nice research. Based on the docs you linked to, this looks like it will indeed resolve the issue for anyone with webpack's @josephfrazier, do you think this should be released as a 4.4.1 or 4.5.0? |
Thanks! This feels like a 4.4.1 bugfix to me |
@slevithan are you going to take care of doing the release, or should I? |
@josephfrazier If you're okay with doing it, I'd really appreciate it! I'm trying to minimize involvement going forward :( But let me know if you run into any problems and I'll be happy to help! |
I should be able to dig up and do all the steps, especially now that you've made it easier with 760ab95 I'll give it a shot and reach out if there's any issues! |
Travis CI is no longer providing CI minutes for open source projects: https://news.ycombinator.com/item?id=25338983 It's also been pretty slow: the build for #308 hasn't started in 13 minutes The config file is based on the template at https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-nodejs#specifying-the-nodejs-version
@slevithan can I get collaborator access to this repo (https://github.com/slevithan/xregexp/settings/access)? Specifically, I'd like to add a branch protection rule that requires the new github action check to pass on PRs: https://github.com/josephfrazier/xregexp/settings/branches |
@josephfrazier You already had collaborator access, so I'm not sure what's up. I just removed then re-invited you. |
Ohh, whoops. I think I meant to ask for maintain or admin access, so I can manage the repo settings at https://github.com/slevithan/xregexp/settings. Here's what it currently looks like for me: |
Changes include: * Remove no longer relevant lastIndex code from replace method, fixes slevithan#287 * Add browser field to package.json to fix webpack: slevithan#308 To generate this commit, I adapted the steps at slevithan#205 (comment) Here's a fuller list of changes that can be needed with new releases: > * Version number > * Update version number and year in headers, config files, README. > * Update year in LICENSE. > * Update version number in `XRegExp.version`. > * Publish > * Publish new git tag. E.g.: > * `git tag -a v3.1.0 -m "Release 3.1.0"`. > * `git push origin v3.1.0`. > * `npm publish`.
@josephfrazier I don't see any option to change collaborators' roles/permissions. I'm guessing that's because this is a personal repo, rather than owned by an organization. I've gone ahead and created a branch protection rule. I set the branch name pattern as (If you continue to need admin access in the future, I'm open to discussing transferring the repo to an organization.) |
Thanks, that looks like it did the trick! For an example, see #312 I don't know if we need to bother with an organization yet, I'll see if I hit future barriers |
Changes include: * Add browser field to package.json to fix webpack: #308 To generate this commit, I adapted the steps at #205 (comment) > Here's a fuller list of changes that can be needed with new releases: > > * Version number > * Update version number and year in headers, config files, README. > * Update year in LICENSE. > * Update version number in `XRegExp.version`. > * Publish > * Publish new git tag. E.g.: > * `git tag -a v3.1.0 -m "Release 3.1.0"`. > * `git push origin v3.1.0`. > * `npm publish`.
This should close #305, see #305 (comment):