relative path in chrome polymer 3 IIS - polymer-2.x

I updated my project from Polymer-2.x to Polymer-3.x and now, when I just open my index,html in my browser I get 'Uncaught TypeError: Failed to resolve module specifier "#polymer/polymer/polymer-element.js". Relative references must start with either "/", "./", or "../".'
I enabled the relative path support in chrome but it still does not work.
With polymer serve it works fine, but I need it to work via IIS because it refers its url in its code and I have routing to do with it. So localhost is not an option for me.
Is there a way, so I can get it work without polymer serve?

As far as I know, the polymer serve-command replaces npm-paths (e.g. #polymer/polymer/polymer-element.js) with relative paths (e.g. ../node_modules/#polymer/polymer/polymer-element.js) to serve these files. So without that command, your browser does not know where the files are located.
To build a polymer project for production the polymer-cli has a command called polymer build to replace these paths automatically and that should solve your problem. Additionally that helpful command may bundle the project and minify your files. Just have a look at the documentation
Alternatively you could just replace them manually with relative paths.

Related

Is it possible to load a file from remote URL (non JS) to be used in WebPack build

I am attempting to load a file from a remote URL during build to be WebPacked. This file is an MDX file and I am using the MDX vue-loader to load this file for use within the Vue application.
The system I am deploying is tenanted with a headless CMS powering some pages across the system. I would like to explore the possibilities of loading the MDX files at build time from a remote URL.
I have placed the MDX files on GitHub Pages with the remote URL passed in as an environment variable at build time.
The result is something like this (the idea here is that I can swap the domain during build to satisfy the tenanted site requirement):
import('https://somedomain.com/content/home.mdx');
This fails with your typical error during build of:
dependencies not found please install them using npm --save https://somedomain.com/content/home.mdx
I can WebPack ignore this import which allows it to build but then it fails to load in the browser as browsers will only load external modules with a MIME type of JS. Not to mention the fact that this hasn't been through the MDX loader so I suspect even if I could get the browser to load it the file would not have been parsed into something usable.
I realise I could copy these files in during the build stage from the remote but I was hopeful that there might be a way to either allow the browser to pull this remote file or WebPack to download this remote file and pack it into the output.
Does anyone have any ideas if this might be possible? Many thanks in advance.
As MDX needs pre-processing during build I think integration with Webpack is the only way.
You can try the SaveRemoteFilePlugin webpack plugin which allows you to download the file from remote to local file system. But maybe it's not what you want as it seems pushing downloaded files directly into dist folder without passing it through rest of the Webpack pipeline...
So probably better option is val-loader which allows executing your own Node scripts during build - here you can find the example which does almost what you need - Fetching Remote data during build

add/remove components in noflo-ui

I've cloned noflo-ui from github and am running locally but cannot figure out how to add/remove components from the noflo-search box. Ideally, I would like to remove all components from the search results and show only a the ones from my component libraries.
The readme states that libraries can be added by modifying preview/component.json, but removing libraries seems to have no effect. After reading through the docs on components and the spec for component.js I tried editing /component.json, and was also unable to change the results which show in the search box. Furthermore, I can't find any documentation on the .noflo property used in components.json.
Am I doing something wrong or is removing default components not an option?
I assume you are using the bundled noflo-browser runtime (iframe). Did you rebuild after editing preview/components.json?
An easier way to use custom component libraries is to do a custom runtime build, for instance based on noflo-app, host it locally, and switch the runtime URL to point there.
This also works with app.flowhub.io so no need to build & run noflo-ui locally.
In addition to editing preview/component.json, you also have to rebuild the iframe runtime components. To do that, run:
$ grunt build
Note that with newer noflo-ui/Flowhub there is actually no need to build the full UI locally. You can use the hosted Flowhub or even the Chrome app, and simply connect it to an iframe runtime you're running somewhere else:
The noflo-browser-app repo gives a nice base to build these from.

Run Dart WebApp on Apache Server

I want to server a Dart application on an Apache server. I added the line
application/dart dart
to the mime.type file in the Apache configuration. Still I get the error
Resource interpreted as Script but transferred with MIME type text/plain: "http://localhost/~d022051/mastermind/web/mm-game.dart".
Another issue is the link to the packages directory. I do not want to have symlinks in the documents directory of the server. Is there a smart way to copy the required packages in the correct version?
This message has nothing to do with Apache.
It's a while that I worked with Apache, but as far as I know you don't need specific settings to serve a Dart client app using Apache. They are just like any other static HTML, CSS, JavaScript, or image files.
You get this message because the entry page (index.html) contains a script tag for a Dart script. After you run pub build there are no Dart scripts (yet) in the build output (this will change when Chrome supports Dart and pub build also generates Dart output).
When the browser finds this (currently redundant) Dart script tag it produces this output. When you want to get rid of this message just remove the script tag from the HTML page in your your_app_package/build/web/index.html file.
EDIT
transformers:
- $dart2js:
'minify': true
commandLineOptions: ['--output-type=dart']
or
commandLineOptions: ['--output-type=dart', '--categories=Server']
I haven't tested if this categories argument has an effect in dart2dart too.
EDIT END
EDIT2
There is also the output type dart-multi which creates one output file per input library.
See https://code.google.com/p/dart/issues/detail?id=21616#c9 for more details.
EDIT2 END
Add the following lines to the pubspec.yaml file of your package (thanks to Günter, who pointed this out):
transformers:
- $dart2js:
'minify': true
commandLineOptions: ['--output-type=dart']
Then run pub build with the option --mode=debug.
This results in a "runnable" Dart application, containing the dart sources and the needed packages. The build directory can then be copied to a location visible to your web server. When loading the corresponding URL in the Dartium browser the application is started.

Testing Dojo with DOH without local Dojo installation

I'm trying to work out how to use DOH to test Dojo modules if I don't install Dojo locally to my project. I'm working in Eclipse and ideally, I'd like something that I can run as part of a Maven build eventually. The Dojo package is 5-20Mb and I don't want to have it stashed in my source control system with each project if possible.
I've tried a few options with the runner.html test runner, but DOH is going to need to find a Dojo somewhere, and then it seems that modules will be found relative to that installation.
Having Dojo installed on my system but not in the project gives me a problem in trying to find the project relative to the location of the dojo.js file. The cross-domain protection prevents me serving up any kind of absolute path as it strips : characters. It also stops me using a Dojo installation served up on a different domain over http.
Is it necessary to have Dojo installed somewhere that I can then define a relative path from dojo.js to the roots of my modules? If not, how do I configure to get around it?
I've not tried this completely cross domain, but yes, you can define paths which may be enough to get you going.
We run our tests using a somewhat complicated deployment (to ensure we don't introduce accidental dojo/doh path dependencies), and our URL looks like this:
http://server/XXX/dev/dohpath/util/doh/runner.html?boot=../../../dojo/dojo.js&dojoUrl=../../../dojo/dojo.js&paths=doh,../dohpath/util/doh;mymodule,../../mymodule&testModule=full.test.module
That is, you fire up the runner, give it both 'boot' and 'dojoUrl' to tell it where Dojo itself lives, use 'paths' to tell DOH where it lives and how to find your own modules.
blech
Whether those relative paths can be made absolute successfuly, and whether it'll work cross-domain is an entirely different matter, I'm afraid. We'll be hitting that problem ourselves in a couple of months.
I've been able to do this with the runner located at http://archive.dojotoolkit.org/nightly/checkout/util/doh/runner.html and a gist.
The trick seems to be to use a path alias in the URL, and use a network-path reference URL (i.e. omit the URL scheme, URL starts with //).
I found this out while trying to answer this question without a local copy of DOH.
Here it is:
http://archive.dojotoolkit.org/nightly/checkout/util/doh/runner.html?testModule=aa&paths=aa,//gist.github.com/gitgrimbo/5406688/raw/e6bc4469ce72dfd6d50e61e885889cb915a3f66b/gistfile1

Browse path / click-though issue

I have Raize 3.0 installed in D2007. For whatever reason, I can't seem to get the Ctr-click to work for loading up it's units, even though that feature works fine on all my other Delphi and Third-Party components.
Here's what I have for Raize on the Library Path:
$(ProgramFiles)\Raize\RC3\Lib6
$(ProgramFiles)\Raize\RC3\Source
...and the Browsing Path:
$(ProgramFiles)\Raize\RC3\Source
Lib6 contains *.dcu and *.dfm files, and Source contains, obviously, the source code. Adding Lib6 to the Browsing path doesn't seem to affect things one way or the other.
I don't get why this Ctrl-click unit-loading feature isn't working, just for this one component. Any ideas what I may be missing?
You shouldn't need Source path in your Library path. Lib6 should be added to Library Path, and Source to Browsing Path.
If you do so, and it still doesn't work, then you have a similar problem with me:
Problem with setting Browsing Path in Delphi option page
For lib path you generally don't need source files. I use:
C:\Program Files\Raize\RC4\Lib\BDS2007
For browsing path you need to specify the language directory, e.g.:
C:\Program Files\Raize\RC4\Source\Lang\English
If this doesn't fix it, does your unit compile without errors?