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

[Bug]: vanilla missing from exports in package.json - but necessary for many plugins #825

Open
JackAtOmenApps opened this issue Dec 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@JackAtOmenApps
Copy link

JackAtOmenApps commented Dec 3, 2024

Bug description

The release docs for 2.4.1 mention updates to exports in package.json. As I was updating django-tomselect to incorporate these changes, I noticed the tiny custom plugin we have, which uses getDom from vanilla, could not be updated to remove the deprecated src/ in the path. In fact, many plugins import various things from vanilla, but when various exports were added in 5979369, vanilla was not among them. This isn't an issue for the built-in plugins, because they use relative imports, but it is an issue for custom plugins.

The issue is that the exports section of package.json does not include vanilla.js

  "exports": {
    ".": {
      "import": "./dist/esm/tom-select.complete.js",
      "require": "./dist/cjs/tom-select.complete.js"
    },
    "./base": {
      "import": "./dist/esm/tom-select.js",
      "require": "./dist/cjs/tom-select.js"
    },
    "./popular": {
      "import": "./dist/esm/tom-select.popular.js",
      "require": "./dist/cjs/tom-select.popular.js"
    },
    "./utils": {
      "import": "./dist/esm/utils.js",
      "require": "./dist/cjs/utils.js"
    },
    "./plugins/*": {
      "import": "./dist/esm/plugins/*",
      "require": "./dist/cjs/plugins/*"
    },
    "./src/*": "./src/*",
    "./dist/*": "./dist/*",
    "./package.json": "./package.json"
  },

I recommend adding the following to exports, which worked perfectly on my local machine:

    "./vanilla": {
      "import": "./dist/esm/vanilla.js",
      "require": "./dist/cjs/vanilla.js"
    },

Expected behavior

Steps to reproduce

See above

Additional context

OS: Ubuntu 24.04
NPM (LTS)
tom-select ^2.4.1

For context, here is the dropdown_footer plugin:

/**
 * Plugin: "dropdown_footer" (Tom Select)
 * Copyright (c) contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the License at:
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
 * ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 *
 */
import { getDom } from 'tom-select/vanilla';

type DFOptions = {
	title	    ?: string,
	footerClass	?: string,
	html	 	?: (data:DFOptions) => string,
};

export default function(this:TomSelect, userOptions:DFOptions) {
    const self = this;

	const options = Object.assign({
		title         : 'Autocomplete Footer',
		footerClass   : 'container-fluid mt-1 px-2 border-top dropdown-footer',

		html: (data:DFOptions) => {
			return (
				'<div title="' + data.title + '" class="' + data.footerClass + '"></div>'
			);
		}
	}, userOptions);

	self.hook('after', 'setup', () => {
		var footer = getDom(options.html(options));

        self.dropdown.appendChild(footer);
	});

};

I am no JavaScript expert, so if I am misunderstanding something, or if there is a better approach than what I recommended here, please let me know.

@JackAtOmenApps JackAtOmenApps added the bug Something isn't working label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant