fix: Webpack out-of-box compatibility #67

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@treshugart

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

Fixes #66

@treshugart treshugart fix: Webpack out-of-box compatibility
Renamed the local define() function to defineElement() so that Webpack (and possibly others) don't try and automatically shim AMD.

Fixes #66
30bd5a4
@WebReflection
Owner

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

@WebReflection
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

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
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

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
Owner

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

@WebReflection WebReflection added a commit that referenced this pull request Aug 24, 2016
@WebReflection fixed #66 and improved #67 0e98e64
@treshugart treshugart deleted the unknown repository branch Aug 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment