dojo loader is appending 'main.js' to my packages - module

For my packages, dojo seems to be appending 'main.js' to end of each file resulting in a '404' has any one experienced this and or have a solution?
GET http://localhost:9000/scripts/prodLayers/main.js 404 (Not Found)
var dojoConfig = {
has: {
"dojo-firebug": true,
"dojo-debug-messages": true
},
tlmSiblingOfDojo: true,
async: true,
parseOnLoad: false,
packages: [
{ name: "prod", location: "/scripts/prodLayers"}
]
};

packages: [
{ name: "prodLayers", location: "/scripts/mylibs", main: "prodLayers"}
]
The "main" attribute is name of the file to be referenced using 'baseUrl' to define the package locations may also help to simplify the "location" params.

Related

Docusaurus | ValidationError: "authorsMapPath" is not allowed

I wanna try to use the global "authors" in the blog markdown file "authorsMapPath" this parameter in the docusaurus.config.js file.
However, whatever I tried in the presets or plugins, I always got this error.
A validation error occured.
The validation system was added recently to Docusaurus as an attempt to avoid user configuration errors.
We may have made some mistakes.
If you think your configuration is valid and should keep working, please open a bug report.
ValidationError: "authorsMapPath" is not allowed
Here is my partial setting in the docusaurus.config.js file.
presets: [
[
'#docusaurus/preset-classic',
{
docs: {
// sidebarCollapsible: true,
sidebarPath: require.resolve('./sidebars.js'),
// Please change this to your repo.
editUrl:
'https://github.com/facebook/docusaurus/edit/master/website/',
},
blog: {
// authorsMapPath: 'authors.yml',
showReadingTime: true,
// Please change this to your repo.
editUrl:
'https://github.com/facebook/docusaurus/edit/master/website/blog/',
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
},
],
],
plugins: [
[
'#docusaurus/plugin-content-blog',
{
authorsMapPath: 'authors.yml',
// Simple use-case: string editUrl
// editUrl: 'https://github.com/facebook/docusaurus/edit/main/website/',
// Advanced use-case: functional editUrl
},
],
],
Is there any idea about my error?
Thank you!
I could resolve this issue after I upgraded #docusaurus/preset-classic version from 2.0.0-alpha.72 to 2.0.0-beta.21.
The code became like below:
presets: [
[
'#docusaurus/preset-classic',
{
docs: {
// sidebarCollapsible: true,
sidebarPath: require.resolve('./sidebars.js'),
// Please change this to your repo.
editUrl:
'https://github.com/facebook/docusaurus/edit/master/website/',
},
blog: {
authorsMapPath: 'authors.yml',
showReadingTime: true,
// Please change this to your repo.
editUrl:
'https://github.com/facebook/docusaurus/edit/master/website/blog/',
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
},
],
],

Error evaluating function `ceil`: argument must be a number

On OSX, after I installed all of dependencies by yarn install, The webpack bundle's output keeps showing the error Error evaluating function ceil: argument must be a number.
I have no idea why this happen but it works on my linux machine with the same package.json
Some info:
webpack: "5.56.0"
less: "^4.1.2"
less-loader: "^10.0.1"
Here is my less-loader config:
{loader: "less-loader"}
It looks like the there is a change of the default options of less based on what I've found in here
https://lesscss.org/usage/#less-options-math
The solution is adding the option for less-loader in webpack config as following:
{
loader: "less-loader",
options: {
lessOptions: {
math: 'always' // <=== add this
}
}
}
Also you should change => strictMath: false
Example (my file config-overrides.js):
const addLessLoader = require("customize-cra-less-loader");
module.exports = override(
addLessLoader({
cssLoaderOptions: {
sourceMap: true,
modules: {
localIdentName: "[hash:base64:8]",
},
},
lessLoaderOptions: {
lessOptions: {
math: "always",
modifyVars: { "#primary-color": "#2a4365" },
javascriptEnabled: true,
strictMath: false,
},
},
})
);

karma-coverage includes node_modules

I have a karma config which for my unit test and code-cov. My project dir looks like below
RootFOlder
-karma.config.js
-webpack.test.config.js
-src/
--test.ts
--components
---ButonComponent
----Buttoncomponent.spec.ts
And my karma.config is below
// Karma configuration
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'src/test.ts',
'src/components/**/*.component.ts',
],
// list of files / patterns to exclude
exclude: [
'node_modules',
'./src/tsconfig.spec.json'
],
plugins: [
require('karma-jasmine'),
require("karma-coverage"),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-webpack'),
require('karma-sourcemap-loader'),
require('ts-loader')
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'src/components/**/*.ts': ['coverage'],
'src/components/**/*.component.ts': ['webpack', 'sourcemap'],
'src/test.ts': ['webpack', 'sourcemap'],
},
webpack: require('./webpack.test.config'),
coverageReporter: {
reporters: [
{ type: 'text', subdir: 'text' },
{ type: 'html', subdir: 'report-html' },
]
},
...
...
});
}
And my webpack.
module.exports = {
devtool: 'inline-source-map',
mode: 'development',
target: 'node',
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
loaders: ['ts-loader', 'angular-router-loader', 'angular2-template-loader']
}
....
....
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'test')
}),
// Removes warnings regarding Critical dependency
new webpack.ContextReplacementPlugin(
/\#angular(\\|\/)core(\\|\/)f?esm5/, path.join(__dirname, './src')
)
],
node: {
console: false,
global: true,
process: true,
Buffer: false,
setImmediate: false
}
}
The problem is after i run my test, my coverage covers the bundled node_modules. The file coverage endup being hude running in MBytes and my coverage low. Pls how do i exclude the node_modules from my coverage? Any help is appreciated .
By default you shouldn't even need to mention node_modules in the exclude path. Try removing it and see if the coverage is corrected?
If not,
try adding this to the preprocessors:
'!node_modules/**/*.*': ['coverage']

How to perform dijit optimization with r.js?

How do we get around the "document is not defined" error when doing a r.js build via r.js -o against a dijit?
Specifically, I'm trying to build r-build.js:
define(["require", "exports", "dijit/layout/ContentPane"], function (require, exports, ContentPane) {
function simple() {
return ContentPane;
}
return simple;
});
Using r.js.cmd -o r-build.js and it reports:
ReferenceError: document is not defined
In module tree:
test/simple
dijit/layout/ContentPane
dijit/_Widget
dojo/query
dojo/selector/_loader
My r-build.js file looks like this:
({
appDir: "../",
baseUrl: "amd",
dir: "../../release",
optimize: "none",
modules: [
{
name: "test/simple",
exclude: ["jquery", "dojo"]
}
],
packages: [
{
name: 'cm',
location: 'http://localhost:93/CodeMirror'
},
{
name: 'jquery',
location: 'd:/code/jquery/src',
main: 'jquery'
},
{
name: 'jquery/ui',
location: 'http://localhost:93/jquery-ui/ui'
},
{
name: 'jquery/themes',
location: 'http://localhost:93/jquery-ui/themes'
},
{
name: 'sizzle',
location: 'http://localhost:93/jquery/external/sizzle/dist',
main: 'sizzle'
},
{
name: 'dojo',
location: 'd:/code/dojo'
},
{
name: 'dijit',
location: 'd:/code/dijit'
},
{
name: 'xstyle',
location: 'http://localhost:93/xstyle'
}
]
})
I'm fighting with the same issue. Building a r.js bundle with Dojo is a pain.
That one can be easy to fix... If you don't have problems with the supported browsers (post pre-ie9, for instance) override that file and change the lines that check the querySelectorAll to true and you will not need to do those checks. Like...
has.add("dom-qsa2.1", true);
has.add("dom-qsa3", true);
Hope it helps a bit...

"Portable Modules" work with the src version, but not the pre-built version

In order to use dojo 1.8 in conjunction with 1.6, I set up portable modules as described in the tutorial Defining Modules, under the sub heading "Using portable modules".
I've been using it with the source version of dojo, "dojo-release-1.8.3-src.zip", and it works just fine, but when I switch to the pre-built version, "dojo-release-1.8.3.zip", it throws 404 errors looking for dependencies:
GET http://localhost:8080/sb/javascript/lib/dojo-release-1.8.3/dojo/parser.js 200 OK
GET http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/_base/url.js 404 Not Found
"NetworkError: 404 Not Found - http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/_base/url.js"
GET http://localhost:8080/sb/javascript/lib/dojo-release-1.8.3/dojo/request.js 200 OK
GET http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/request/default.js 404 Not Found
"NetworkError: 404 Not Found - http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/request/default.js"
From the console it's clear that it's looking in the wrong place for the dependency file (looking in 'dojo-build-1.6.1' instead of 'dojo-release-1.8.3'). What I want to know is why? All I did was swap the source version for the pre-built version.
Here is my configuration:
<script>
var map18 = {dojo: "dojo18", dijit: "dijit18", dojox: "dojo18"};
var dojoConfig = {
async: false,
parseOnLoad: true, // in 1.8 they suggest setting to false and manually parsing when needed, but we're not set up that way at the moment
packages: [
{name: "dgrid", location: "../../dgrid/dgrid", packageMap: map18},
{name: "xstyle", location: "../../dgrid/xstyle", packageMap: map18},
{name: "put-selector", location: "../../dgrid/put-selector", packageMap: map18},
{name: "modules", location: "../../modules", packageMap: map18},
{name: "page", location: "../../page"},
{name: "dojoc", location: "../../dojoc"},
{name: "dojo18", location: "../../dojo-release-1.8.3/dojo", packageMap: map18},
{name: "dijit18", location: "../../dojo-release-1.8.3/dijit", packageMap: map18},
{name: "dojox18", location: "../../dojo-release-1.8.3/dojox", packageMap: map18},
{name: "dojo", location: "../../dojo-build-1.6.1/dojo", main: "dojo"},
{name: "dijit", location: "../../dojo-build-1.6.1/dijit"},
{name: "dojox", location: "../../dojo-build-1.6.1/dojox"}
],
};
</script>
I tried something similar (using both 1.8 and 1.6 source) and got a different error. I know it's not an answer to the question, but I'll paste it here in case it helps you find an answer.
This is my test page:
<script>
var location18 = "/dojo18";
var location16 = "/dojo16";
var map16 = { dojo: "dojo16", dijit: "dijit16", dojox: "dojox16" },
dojoConfig = {
packages: [
{ name: "dojo16", location: location16 + "/dojo", packageMap: map16 },
{ name: "dijit16", location: location16 + "/dijit", packageMap: map16 },
{ name: "dojox16", location: location16 + "/dojox", packageMap: map16 },
{ name: "dojo", location: location18 + "/dojo" },
{ name: "dijit", location: location18 + "/dijit" },
{ name: "dojox", location: location18 + "/dojox" }
]
};
</script>
<script src="/dojo18/dojo/dojo.js"></script>
<script>
require(["dojo/date"], function (date) {
console.log("date18", date);
});
</script>
<script>
require(["dojo16/date"], function (date) {
console.log("date16", date);
});
</script>
And the error I get seems to be related to loading two date modules. Not sure if Dojo can treat them separately, but I've not managed to do this.