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

Make it possible to export .mjs packages that would work against canjs's core.mjs #1088

Open
justinbmeyer opened this issue Nov 5, 2018 · 2 comments

Comments

@justinbmeyer
Copy link
Contributor

can-crud is built similar to how canjs's packages are built:

var Component = require("can-component");

Component.extend({
	tag: "can-crud",
	...
})

While this is great for npm and a module loader, this doesn't make it easy to use on something like a codepen. I'd like something like the following to work:

import "//unpgk.com/can-crud@1";
import {Component} from "//unpgk.com/can@5";

Where //unpgk.com/can-crud@1 is importing canjs from //unpgk.com/can@5.

I'm not sure how this could work. Possibly via some mapping, including being able to import a mapping from can:

var importMapping = require("can/import-map.json");
importMapping //-> {"can-component": {package: "can", name: "Component"}}

stealTools.export({
	...
	outputs: {
		"something es6": {
			map: importMapping
		}
	}
});
@justinbmeyer
Copy link
Contributor Author

  • add ability to convert to CJS to ES modules
  • map from require to named import

@matthewp
Copy link
Member

matthewp commented Nov 9, 2018

I think steal-tools should have some new builds, for CDN and for native module usage. I would want something like:

dist/
  es/
    unpkg/
      can-component.js
    local/
      can-component.js

In the "local" build module specifiers have been rewritten to be point to the node modules. For example the above might do `import stache from "../../../../node_modules/can-stache/dist/local/can-stache.js". This is nice because you can work locally and things will be generally fast. The downside here would be that it expects a "flat" node_modules, so you if have multiple versions of any packages that will not work.

In the "unpkg" build module specifiers have been rewritten to point to a CDN (unpkg or maybe configurable). It will be like import stache from "https://unpkg.com/can-stache@^4.0.0/dist/unpkg/can-stache.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants