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

Add tests for liferay-npm-bundler #16

Merged
merged 4 commits into from
Aug 17, 2017
Merged

Conversation

izaera
Copy link
Member

@izaera izaera commented Jul 12, 2017

No description provided.

@izaera izaera requested a review from jbalsas as a code owner July 12, 2017 10:19
@jbalsas jbalsas requested a review from robframpton July 12, 2017 11:00
@jbalsas
Copy link
Contributor

jbalsas commented Jul 12, 2017

Hey @Robert-Frampton, this is the biggest thing we need to complete our framework/workflow story for Liferay Portal. Could you take a look at the architecture and provide some feedback?

@izaera, could you explain briefly here what this is supposed to do and why so Rob has some context?

@izaera
Copy link
Member Author

izaera commented Jul 12, 2017

Explanation: this is a kind of bundler (the technical name for tools like browserify) that targets liferay-portal. Normal bundlers generate one large js file with all deps inside (some may split it in chunks, but conceptually it is just one file) but we don't, because we resolve package dependencies in the very last moment: when rendering the page. This is because we need to mix several portlets which, in the end, are like tiny nearly-isolated web apps.

Said that, when we package an OSGi bundle JAR, we:

  1. Put all NPM dependencies (only the ones really needed by the project) inside the JAR
  2. Pre process each dependency package with npm-bundler plugins
  3. Process each dependency package by running Babel on all source files and copying the rest verbatim
  4. Post process each dependency package with npm-bundler plugins

And this is the tool that does those things.

The rationale behind 2, 3, and 4 is that 2 prepares the package before running Babel, 3 runs Babel to wrap modules inside AMD defines, normalize things, shim things, and the like, and 4 polishes Babel's output if necessary.

Hope this explains everything and makes it clear like a crystall ball ;-).

@robframpton
Copy link
Contributor

Hey @izaera

What's the best way to examine what the output looks like? Is there a test module you've been using?

@izaera
Copy link
Member Author

izaera commented Aug 8, 2017

@Robert-Frampton Sorry for not answering. Looks like I missed the notification :-(.

There's this repo with examples: https://github.com/izaera/liferay-npm-examples . You can build the projects in there and examine the generated JARs. There are examples for several libraries/frameworks (react, vue, angular, ...).

@robframpton
Copy link
Contributor

Hey @izaera

Awesome, I'll take a look today.

Thanks!

@izaera
Copy link
Member Author

izaera commented Aug 16, 2017

@Robert-Frampton Did you manage to find some time to look at this?

@robframpton robframpton merged commit 2ef8eaa into liferay:master Aug 17, 2017
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.

4 participants