How to import legacy JavaScript modules / AMD modules in ES6? - ecmascript-6

How to import legacy JavaScript modules / AMD modules in ES6?
In this context,
Legacy module means: module which pollute global namespace
AMD module means: module which work with require.js
Is this possible?

Related

NewtonsoftJson being accepted in ASP.NET core 3.0 rc1 application

This is more of a 'why is .NET okay with this?' kind of question. The documentation for migrating to 3.0 said to that NewtonsoftJson is no longer built into the shared framework.
I have a couple libraries that are netstandard2.0 which use Newtonsoft.json package in which my 3.0 application is dependent. However, I am getting no complaints from my 3.0 application by just using using Newtonsoft.Json in the file. I don't have the recommended 3.0 Mvc.NewtonsoftJson package in the 3.0 project file either.
This article mentions using the System.Text.Json NuGet package in .netstandard projects. Should I be doing this then?
ASP.NET Core Mvc no longer uses Newtonsoft.Json as the default json serializer but, it could still be enabled with:
Install the package with dotnet add package Microsoft.AspNetCore.Mvc.NewtonsoftJson --version 3.0.0-rc1.19457.4
Add AddNewtonsoftJson() after AddMvc(), AddControllers(), AddRazorPages(), or AddControllersWithViews().
System.Text.Json is recommended as default but there is no reason for ASP.NET Core to disallow you to useNewtonsoft.Json, it just does not include or use it as default.
You could continue to use Newtonsoft.Json in your .NET Standard 2.0 library project, but for better performance, you could install the package with dotnet add package System.Text.Json --version 4.6.0-rc1.19456.4 and migrate all uses of Newtonsoft.Json to System.Text.Json. But note that System.Text.Json is still very new and not as full-featured as Newtonsoft.Json, and some behavior would differ.

Add a Webpack 'loader' to `polymer build`

Is there any way to add a Webpack loader to Polymer 3.0's build and serve CLI?
I'm familiar with using Webpack to build Polymer apps, but not with the Polymer CLI — I didn't find a public interface, but I didn't look for long.

lit-element with javascript dependencies that are not packaged as es6 modules (yet)

I'm creating a lit-element that has an external javascript dependency (npm module) that is not packaged as an es6 module. What is the recommended way of loading this dependency?
Should I just use a script tag in my index.html that references the cdn version of this module
//index.html
<script src="cdnToexternalJavascriptDependcy"></script>
but that would not encapsulate the dependency within the lit-element.
In Polymer, we can just use HTMLImports inside a html file and "import" it which would handle deduplication of dependencies.
For lit-element, what is the recommended way of encapsulating this "non-es6-module" dependency within my custom lit-element without using a bundler like webpack?
You can load it as normal script. If you load it from CDN it will not be included in the bundle. If you load it from node_modules folder when you use polymer build it'll bundle the dependency.

Junit in atom or sublime

I would rather use a lightweight text editor than eclipse (for a few reasons) but I can't seem to figure out how to import the junit JAR into my project without using eclipse. I don't know the java ecosystem very well, what is the best way of achieving this in either editor? or both? Thanks.
I tried putting the junit-4.12 JAR inside my java/jdk/lib/ext folder so that its in the build path of the java compiler, I read somewhere this works, though when I try the following imports I get the error:
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
TTester.java:6: error: package org.junit does not exist
import static org.junit.Assert.*;
^ TTester.java:10: error: package org.junit does not exist import org.junit.Before;
^TTester.java:11: error: package org.junit does not exist import org.junit.Test;
Using a text editor for a java application is going to be painful. You could look at some of these packages:
https://atom.io/packages/search?q=java
But I would recommend either Eclipse or IntelliJ Community edition - my personal preference is the latter. Java development beyond the most simple case really needs a full-blown IDE.

react-router, server sided rendering with Koa/Express. How to import/export compiled routes

My React app imports images sass and fonts and other modules/plugins which all should be compiled before going in production by Webpack.
How can I render server sided and import the routes from from the compiled React app?
Running a second Webpack config which will compile the server sided JS root file does the trick.
This starter kit is very barebones and gives a clear view of what needs to be done:
https://github.com/RickWong/react-isomorphic-starterkit