Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Conversation

@treshugart
Copy link

Renamed the local define() function to defineElement() so that Webpack (and possibly others) don't try and automatically shim AMD.

Fixes #66

Renamed the local define() function to defineElement() so that Webpack (and possibly others) don't try and automatically shim AMD.

Fixes #66
@WebReflection
Copy link
Owner

my main concern is that WebPack shouldn't pick the src file, otherwise more will miss and break.

@WebReflection
Copy link
Owner

for instance, this folder has all the builds and these have a callback.
https://github.com/WebReflection/document-register-element/tree/master/build

I will change the function name but I need to also make build folder but yet I'd like to understand what is Webpack doing. All files are built via Makefile and if I can tell Webpack which file it should pick, I'd prefer this way instead of letting it guess the right one.

@treshugart
Copy link
Author

Generally Webpack (and other build tool) users might pick the unminified source (build/document-register-element.max.js) to avoid any possible issues from double-minifying. They could tell the minifier not to minify this file, but that's not as nice as not having to worry about it and it's not something that they'd look for up front, I wouldn't think. From what I've seen, the general package.json convention for main is to point to an unminified souce while a minified source is compiled next to it for manual consumption.

I'm not sure what Webpack does and it's unfortunate you'd have to do something like this to get around it, but maybe it's best to be defensive for tools doing funny things?

@WebReflection
Copy link
Owner

if webpack imports my script on a global scope capable of overwriting AMD define function it doesn't matter if the source is minified or not because everything will break regardless.

I will publish next package.json pointing at the max file but still ... I'd love to know what is Webpack doing

@treshugart
Copy link
Author

Yeah not sure. FWIW, the minified file worked for me and doing this fixed it for the max file. I know at a higher level they test the name of the function being referenced in the AST, but probably not if it's already been defined in that scope. This may be file-able under Webpack's issue tracker for that matter, but I'm unsure as to how other tools would behave.

@WebReflection
Copy link
Owner

I gonna quickly publish latest even if in not a perfect shape (still some desktop FF hiccups) but these issues should go.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants