I'm trying to precompile external files to get their assets with this script:
#!/usr/bin/env perl6
use v6;
use nqp;
my $precomp-store = CompUnit::PrecompilationStore::File.new(prefix => "/tmp".IO);
our $precomp = CompUnit::PrecompilationRepository::Default.new(store => $precomp-store);
my $file = "./test.pm6";
my $io = $file.IO;
my $id = nqp::sha1(~$file);
my $handle = $precomp.load($id)[0];
without $handle {
$precomp.precompile($io, $id, :force);
$handle = $precomp.load($id)[0] // fail("Could not precompile $file for $!");
}
The file I'm using is this:
use Test;
=begin pod
This is a simple pod
=end pod
If I turn RAKUDO_MODULE_DEBUG on, it fails with more stuff, but the important part is here:
precomp [master●] % perl6 precomp.p6
1 RMD: Loading settings CORE
1 RMD: going to load Perl6::BOOTSTRAP
1 RMD: Settings CORE loaded
1 RMD: Loading settings CORE.d
1 RMD: Settings CORE.d loaded
1 RMD: Attempting 'nqp' as a pragma
1 RMD: Successfully handled 'nqp' as a pragma
1 RMD: Trying to load 1547B8DB721297B89EF50BE4C8A107F9B5D21542 from /tmp
1 RMD: Trying to load 1547B8DB721297B89EF50BE4C8A107F9B5D21542.repo-id from /tmp
1 RMD: dependency: 2D4A7CA10695CD2B374573413D261A660E282E2A perl#sources/2D4A7CA10695CD2B374573413D261A660E282E2A D211A39B814DE8D3F38300E0D20E3D0AD2CC31FC CompUnit::DependencySpecification.new(short-name => "Test", source-line-number => 1, from => "Perl6", version-matcher => Bool::True, auth-matcher => Bool::True, api-matcher => Bool::True)
1 RMD: Could not find Test
Use of uninitialized value of type Str in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at precomp.p6 line 14
1 RMD: Outdated precompiled /tmp/F2356FF85D653556C42648576BF9FD57907BCA26/15/1547B8DB721297B89EF50BE4C8A107F9B5D21542
mtime: Instant:1544952082.231729
checksum: 35C697BFF7987CFB69E25F56B3EFCB2BD79D75DA, expected:
1 RMD: Precompiling ./test.pm6 into /tmp/F2356FF85D653556C42648576BF9FD57907BCA26/15/1547B8DB721297B89EF50BE4C8A107F9B5D21542.bc ( )
2 RMD: Loading settings CORE
2 RMD: going to load Perl6::BOOTSTRAP
2 RMD: Settings CORE loaded
2 RMD: Loading settings CORE.d
2 RMD: Settings CORE.d loaded
1 RMD: Precompiled ./test.pm6 into /tmp/F2356FF85D653556C42648576BF9FD57907BCA26/15/1547B8DB721297B89EF50BE4C8A107F9B5D21542.bc
1 RMD: Writing dependencies and byte code to /tmp/F2356FF85D653556C42648576BF9FD57907BCA26/15/1547B8DB721297B89EF50BE4C8A107F9B5D21542.tmp for source checksum: F2F1395843988DF3C47A50DA40CF3B864959FB14
1 RMD: Trying to load 1547B8DB721297B89EF50BE4C8A107F9B5D21542 from /tmp
1 RMD: Trying to load 1547B8DB721297B89EF50BE4C8A107F9B5D21542.repo-id from /tmp
1 RMD: Loading precompiled
/tmp/F2356FF85D653556C42648576BF9FD57907BCA26/15/1547B8DB721297B89EF50BE4C8A107F9B5D21542
The gist of it is that it's not finding the module Test. This probably means that PrecompilationRepository is trying to find Test in the context of the same precompilation repository, which makes sense. So the question is: is that assumption correct? If it is, how can we inject that library path into the precompilation store? Or should we just use the default precompilation store? How could we do that?
Related
With vue.js when setting up a project using vue CLI i can run
$ npm run serve
to compile the files and start a port at localhost:8080
My question is what can i do so that the generated that got rendered in the page be also saved to a directory in my development machine.
Just like auto-saving and modifying so that i can be able to use the file on another project which depends on the generated files all during development
Are you sure it's not already creating a bundle somewhere? In some kind of build or dist folder?
Inside the webpack config you can check what value is used for output.
I don't know if an easier solution exists. But what i would suggest is :
Set writeToDisk option true. This will make sure your bundle written in to disk. Link
Then add an after-emit hook to the webpack pipeline:
const exec = require('child_process').exec; // use exec to run shell command
module.exports = {
...
plugins: [
...
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap('CopyOutputPlugin', (compilation) => {
exec('command to copy output folder to desired folder');
});
}
}
]
};
child_process documentation.
(npm vue -V => 3.2.1)
I'm trying to compile a single file component test1.vue to a *.js file(s) in order to include it in an existing project. My intention is to get a test1.jsfile (and in production mode the chunk-vendors.js file).
What I tried until now:
vue build ./src/test1.js
with result:
I don't want the file to be app.js so I put:
module.exports = {
filenameHashing: false,
chainWebpack: config => {
config.entryPoints.delete('app')
delete config.entry.app
config.entry('test1')
.add('./src/test1.js')
.end()
}
}
into vue.config.js and got this:
so far so good!
When I try
vue-cli-service build src/test1.js --mode development --name test1
I get always app.js. Is there a way to get the test1 name in development mode also?
P.S. Manual rename in the file system is a (not nice) solution I know of.
(I could not put vue-cli-service tag to this post as it requires 1500 reputation. wow!)
I created an app with the SPA Templates. The Angular app is using the primeng components for the UI. In order to get the bootstrap, fontawesome and primeng themes running I ran webpack --config webpack.config.vendor.js so that I could add the css files to the nonTreeShakableModules array. Everything seems to work until I publish.
When I attempt to publish I get the following error
ERROR in ./$$_gendir/~/primeng/components/menu/menu.ngfactory.ts
Module parse failed: .\$$_gendir\node_modules\primeng\components\menu\menu.ngfactory.ts Unexpected token (14:32)
You may need an appropriate loader to handle this file type.
| import * as i3 from '#angular/router';
| import * as i4 from 'primeng/components/dom/domhandler';
| export const MenuModuleNgFactory:i0.NgModuleFactory<i1.MenuModule> = i0.?cmf(i1.MenuModule,
| ([] as any[]),(_l:any) => {
| return i0.?mod([i0.?mpd(512,i0.ComponentFactoryResolver,i0.?CodegenComponentFactoryResolver,
# ./$$_gendir/ClientApp/app/components/locations/locations.component.ngfactory.ts 9:0-99
# ./$$_gendir/ClientApp/app/components/list/list.component.ngfactory.ts
# ./$$_gendir/ClientApp/app/app.module.server.ngfactory.ts
# ./ClientApp/boot.server.ts
I have this error for every primeng component that is used.
You might be experiencing this because The ASP.NET core 2.0 / Angular Template uses different typescript loaders for development and for production : awesome-typescript-loader and angular2-template-loader in development, and #ngtools/webpack in production.
From my experience, #ngtools/webpack doesn't do well with loading some third party angular components. You could try using awesome-typescript-loader and angular2-template-loader for both development and production.
I have a simple, bare-bones integration test for a component which depends on an i18n service (which the test injects). The component itself is a simple select dropdown from ember-select-list, with a default value of Select Language. Here's the test:
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('language-select', 'Integration | Component | language select', {
integration: true,
beforeEach() {
this.inject.service('i18n');
}
});
test('it renders', function(assert) {
this.render(hbs`{{language-select}}`);
assert.equal(this.$().text().trim().includes('Select Language'), true);
});
When I attempt to just run this one test file (i.e. ember test -f "language-select"), the output I see indicates that only linting tests were performed:
[ hospitalrun-frontend ] $ ember test -f "language-select"
WARNING: Node v7.5.0 is not tested against Ember CLI on your platform. We recommend that you use the most-recent "Active LTS" version of Node.js.
cleaning up...
Built project successfully. Stored in "/Users/richie.thomas/Desktop/Workspace/OpenSource/hospitalrun-frontend/tmp/core_object-tests_dist-5MT1adu7.tmp".
ok 1 PhantomJS 2.1 - ESLint - acceptance/language-select-test.js: should pass ESLint
ok 2 PhantomJS 2.1 - ESLint - components/language-select.js: should pass ESLint
ok 3 PhantomJS 2.1 - TemplateLint - hospitalrun/templates/components/language-select.hbs: should pass TemplateLint
ok 4 PhantomJS 2.1 - ESLint - integration/components/language-select-test.js: should pass ESLint
1..4
# tests 4
# pass 4
# skip 0
# fail 0
# ok
However when I run a plain ember test, I see that this test fails because I am apparently injecting the i18n service incorrectly:
not ok 488 PhantomJS 2.1 - Integration | Component | language select: it renders
---
actual: >
null
expected: >
null
stack: >
http://localhost:7357/assets/hospitalrun.js:4090:18
get#http://localhost:7357/assets/vendor.js:35757:32
get#http://localhost:7357/assets/vendor.js:40664:22
compute#http://localhost:7357/assets/vendor.js:33758:29
value#http://localhost:7357/assets/vendor.js:33625:52
value#http://localhost:7357/assets/vendor.js:65639:37
value#http://localhost:7357/assets/vendor.js:33512:34
create#http://localhost:7357/assets/vendor.js:31495:53
evaluate#http://localhost:7357/assets/vendor.js:66320:43
execute#http://localhost:7357/assets/vendor.js:72898:36
render#http://localhost:7357/assets/vendor.js:72472:30
render#http://localhost:7357/assets/vendor.js:30793:52
runInTransaction#http://localhost:7357/assets/vendor.js:41756:28
_renderRoots#http://localhost:7357/assets/vendor.js:31058:64
_renderRootsTransaction#http://localhost:7357/assets/vendor.js:31096:26
_renderRoot#http://localhost:7357/assets/vendor.js:31017:35
_appendDefinition#http://localhost:7357/assets/vendor.js:30930:23
appendOutletView#http://localhost:7357/assets/vendor.js:30913:29
invoke#http://localhost:7357/assets/vendor.js:19795:19
flush#http://localhost:7357/assets/vendor.js:19865:15
flush#http://localhost:7357/assets/vendor.js:19989:20
end#http://localhost:7357/assets/vendor.js:20059:28
run#http://localhost:7357/assets/vendor.js:20182:19
run#http://localhost:7357/assets/vendor.js:40972:32
render#http://localhost:7357/assets/test-support.js:20665:30
http://localhost:7357/assets/tests.js:15398:16
runTest#http://localhost:7357/assets/test-support.js:3859:34
run#http://localhost:7357/assets/test-support.js:3845:13
http://localhost:7357/assets/test-support.js:4037:15
advance#http://localhost:7357/assets/test-support.js:3522:26
begin#http://localhost:7357/assets/test-support.js:5213:27
http://localhost:7357/assets/test-support.js:4407:11
message: >
Died on test #1 http://localhost:7357/assets/tests.js:15392:24
exports#http://localhost:7357/assets/vendor.js:123:37
requireModule#http://localhost:7357/assets/vendor.js:38:25
require#http://localhost:7357/assets/test-support.js:19547:14
loadModules#http://localhost:7357/assets/test-support.js:19539:21
load#http://localhost:7357/assets/test-support.js:19569:33
http://localhost:7357/assets/test-support.js:7584:22: undefined is not an object (evaluating 'i18n.get')
Log: |
...
I don't see anything in the documentation here about the filter flag affecting the type of tests that are run (i.e. lint vs non-lint tests).
I'm happy to post a separate question about how to properly inject the i18n service, but my question here is:
Why does adding the filter flag result in only filtering tests being run?
It filters module names, not file names. You have dash inside a filter string. Remove it and use space instead:
ember test -f "language select"
I want to precompile my ember templates. I installed an application for that, but I can only precompile one file.
I need like to select all files with .hbs extension including subfolders
I tried ember-precompile "components/**/*.hbs" -f precompiledTemplates.js
I get error saying
Error: ENOENT, no such file or directory 'components\**\*.hbs'
How do I say the program to look for .hbs files in all subfolders ?
I figured it's probably not a windows problem, but a limitation of the library I wanted to use(ember-precompile).
Instead I chose to use gulp which works well https://www.npmjs.org/package/gulp-ember-handlebars
Here's my coffeescript gulpfile for precompiling ember templates. After initiating gulp, it compiles my templates, and if one of templates changes, gulp recompiles.
gulp = require("gulp")
concat = require("gulp-concat")
handlebars = require("gulp-ember-handlebars")
gulp.task( "default", ["precompile-ember-templates"], ()->
# default tasks complete
)
gulp.task( "precompile-ember-templates", ()->
console.log("recompiling templates")
gulp.src( ["client/components/**/*.hbs"] )
.pipe( handlebars({outputType: 'browser'}) )
.pipe( concat("templates-compiled.js") )
.pipe( gulp.dest("client/public/") )
)
gulp.watch( "client/components/**/*.hbs", ["precompile-ember-templates"] )
There does seem to be a limitation within the Ember-Precompile code when handling the windows file structure and wildcards.
When running ember-precompile on windows you must do so through a cygwin terminal or similar (in my case I use git bash).
As an example in git bash when I type the line below in my project folder it works for me:
ember-precompile templates/*.handlebars -f templates/templates.js