vue cli 3 - ProvidePlugin doesn't work (vue.config.js) - webpack-4

I am trying to add webpack.ProvidePlugin which isn't working on Vue-cli 3.
I also tried to set lodash as a global import (so I won't have to import it in each store module).
vue.config
const webpack = require("webpack");
module.exports = {
configureWebpack: {
plugins: [new webpack.ProvidePlugin({ _: "lodash" })]
}
};
build Error:
Module Warning (from ./node_modules/eslint-loader/index.js):
error: '_' is not defined (no-undef) at src/store/modules/templates.js:24:10:
22 | export default Object.assign({}, base, {
23 | namespaced: true,
> 24 | state: _.cloneDeep(initialState),
| ^
25 | mutations: {
26 | addTemplate(state, template) {
27 | if (!template) throw new Error("template is missing");
I built the project after adding the lines to vue.config and they gave me the aforementioned error.

The issue doesn't seem to be with Vue CLI but with eslint. See this question for a similar issue (just replace d3 with _): Webpack not including ProvidePlugins
In short, adding this to your eslint config (often found in .eslintrc.js) should make it work:
"globals": {
"_": true
}

Related

Expo fastlane build fails due to issue with logging in EXUpdates / expo-updates

I get this error message when building an IOS app on an expo managed worfklow for SDK 46. The error appears at the end of the log, at line 716: 'Logger' initializer is inaccessible due to 'internal' protection level. The expo-updates package is installed with the latest version (0.15.6).
The expo doctor command shows nothing wrong with the project.
Compiling expo-eas-client Pods/EASClient » EASClient-dummy.m
› Packaging expo-eas-client Pods/EASClient » libEASClient.a
› Executing expo-eas-client Pods/EASClient » Copy generated compatibility header
› Executing expo-updates Pods/EXUpdates » [CP-User] Generate app.manifest for expo-updates
❌ (node_modules/expo-updates/ios/EXUpdates/Logging/UpdatesLogger.swift:15:24)
13 | public static let EXPO_UPDATES_LOG_CATEGORY = "expo-updates"
14 |
> 15 | private let logger = Logger(category: UpdatesLogger.EXPO_UPDATES_LOG_CATEGORY, options: [.logToOS, .logToFile])
| ^ 'Logger' initializer is inaccessible due to 'internal' protection level
16 |
17 | // MARK: - Public logging functions
18 |
❌ (node_modules/expo-updates/ios/EXUpdates/Logging/UpdatesLogger.swift:15:91)
13 | public static let EXPO_UPDATES_LOG_CATEGORY = "expo-updates"
14 |
> 15 | private let logger = Logger(category: UpdatesLogger.EXPO_UPDATES_LOG_CATEGORY, options: [.logToOS, .logToFile])
| ^ extra argument 'options' in call
16 |
17 | // MARK: - Public logging functions
18 |
❌ (node_modules/expo-updates/ios/EXUpdates/Logging/UpdatesLogger.swift:15:93)
13 | public static let EXPO_UPDATES_LOG_CATEGORY = "expo-updates"
14 |
> 15 | private let logger = Logger(category: UpdatesLogger.EXPO_UPDATES_LOG_CATEGORY, options: [.logToOS, .logToFile])
| ^ reference to member 'logToOS' cannot be resolved without a contextual type
16 |
17 | // MARK: - Public logging functions
18 |
❌ (node_modules/expo-updates/ios/EXUpdates/Logging/UpdatesLogger.swift:15:103)
13 | public static let EXPO_UPDATES_LOG_CATEGORY = "expo-updates"
14 |
> 15 | private let logger = Logger(category: UpdatesLogger.EXPO_UPDATES_LOG_CATEGORY, options: [.logToOS, .logToFile])
| ^ reference to member 'logToFile' cannot be resolved without a contextual type
16 |
17 | // MARK: - Public logging functions
18 |
❌ (node_modules/expo-updates/ios/EXUpdates/Logging/UpdatesLogReader.swift:15:32)
13 | public class UpdatesLogReader: NSObject {
14 | private let serialQueue = DispatchQueue(label: "dev.expo.updates.logging.reader")
> 15 | private let logPersistence = PersistentFileLog(category: UpdatesLogger.EXPO_UPDATES_LOG_CATEGORY)
| ^ cannot find 'PersistentFileLog' in scope
16 |
17 | /**
18 | Get expo-updates logs newer than the given date
▸ ** ARCHIVE FAILED **
▸ The following build commands failed:
▸ CompileSwift normal arm64 (in target 'EXUpdates' from project 'Pods')
▸ CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'EXUpdates' from project 'Pods')
▸ (2 failures)
2023-01-06 08:55:22.238 xcodebuild[4410:14072] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2023-01-06 08:55:22.238 xcodebuild[4410:14072] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2023-01-06 08:55:22.327 xcodebuild[4410:14072] XType: failed to connect - Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.fonts was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.fonts was invalidated: failed at lookup with error 3 - No such process.}
2023-01-06 08:55:22.328 xcodebuild[4410:14072] Font server protocol version mismatch (expected:5 got:0), falling back to local fonts
2023-01-06 08:55:22.328 xcodebuild[4410:14072] XType: unable to make a connection to the font daemon!
2023-01-06 08:55:22.328 xcodebuild[4410:14072] XType: XTFontStaticRegistry is enabled as fontd is not available.
** ARCHIVE FAILED **
The following build commands failed:
CompileSwift normal arm64 (in target 'EXUpdates' from project 'Pods')
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'EXUpdates' from project 'Pods')
(2 failures)
Exit status: 65
+-------------+-------------------------+
| Build environment |
+-------------+-------------------------+
| xcode_path | /Applications/Xcode.app |
| gym_version | 2.206.1 |
| sdk | iPhoneOS15.5.sdk |
+-------------+-------------------------+
The issue was solved by upgrading to Expo SDK 47.

Unable to load strapi instance in unit testing

I am trying to run test cases for strapi but it is not allowing me to do so. I am using postgres database.
I have checked other answers and I have only one database.js file and not database.json
The error I get-
lerna ERR! yarn run test:local stderr:
● process.exit called with "1"
7 | async function setupStrapi() {
8 | if (!instance) {
> 9 | instance = await Strapi().load();
| ^
10 | await instance.app
11 | .use(instance.router.routes()) // populate KOA routes
12 | .use(instance.router.allowedMethods()); // populate KOA methods
at Strapi.stop (../../node_modules/strapi/lib/Strapi.js:316:13)
at Strapi.stopWithError (../../node_modules/strapi/lib/Strapi.js:302:17)
at ../../node_modules/strapi-connector-bookshelf/lib/mount-models.js:688:18
at module.exports (../../node_modules/strapi-connector-bookshelf/lib/mount-models.js:708:7)
at mountConnection (../../node_modules/strapi-connector-bookshelf/lib/index.js:84:7)
at async Promise.all (index 0)
at Object.initialize (../../node_modules/strapi-database/lib/connector-registry.js:30:9)
at DatabaseManager.initialize (../../node_modules/strapi-database/lib/database-manager.js:43:5)
at Strapi.load (../../node_modules/strapi/lib/Strapi.js:362:5)
at setupStrapi (tests/helpers/setup.js:9:16)
error Command failed with exit code 1.
Any leads to fix this?

How can I speed up development builds while developing a linked package? (Ember/Broccoli)

My Broccoli builds take up a LOT of time. ~30 seconds to build every time I change a line of js (I mean the incremental re-builds with dev server running, NOT a complete build).
Here's my situation. I have project A which is an ember addon to project B which I npm link in. As I'm developing project A, I am running ember server on project B.
EVERY SINGLE TIME that I make a change to a line of javascript in project A and rebuild, I see that the following files change in project B:
B/dist/assets/vendor.css
B/dist/assets/vendor.js
B/dist/assets/vendor.map
B/dist/assets/B.css
B/dist/assets/B.css.map
My concern is that, because I'm developing a linked package, my broccoli configuration is such that the entire node_modules is recombined into those vendor files.
Is there a way for me to configure ember/broccoli to use a separate file to compile A into and segregate it from the rest of vendor.js? B/dist/assets/A.min.css and B/dist/assets/A.min.js for example?
...or I'm a guessing at the cause of the problem incorrectly?
Thank you so much for your help in advance!
Edit: Here's some extra info as requested
Slowest Nodes (totalTime => 5% ) | Total (avg)
----------------------------------------------+---------------------
Concat (11) | 39239ms (3567 ms)
RecastFilter (280) | 33127ms (118 ms)
Babel (233) | 14099ms (60 ms)
EslintValidationFilter (5) | 12632ms (2526 ms)
LessCompiler (46) | 7191ms (156 ms)
Slowest Nodes (totalTime => 5% ) | Total (avg)
----------------------------------------------+---------------------
SourceMapConcat: Concat: Vendor /asset... (1) | 36270ms
LessCompiler (46) | 4029ms (87 ms)
Here's the index.js (Of project A):
const EngineAddon = require('ember-engines/lib/engine-addon');
const TreeMerger = require('broccoli-merge-trees');
const LessCompiler = require('broccoli-less-single');
const Funnel = require('broccoli-funnel');
const path = require('path');
module.exports = EngineAddon.extend({
name: 'ember-engine-admin-ui',
lazyLoading: false,
treeForVendor(tree) {
let addonTree = this.treeGenerator(path.resolve(this.root, this.options.trees.addon));
let compiledLessTree = new LessCompiler(addonTree, 'styles/addon.less', `styles/${this.name}.css`);
let sidebarCSSTree = new Funnel(path.dirname(require.resolve('sidebar-v2/css/leaflet-sidebar.css')), {
files: ['leaflet-sidebar.css'],
destDir: 'styles'
});
let sidebarJSTree = new Funnel(path.dirname(require.resolve('sidebar-v2/js/leaflet-sidebar.js')), {
files: ['leaflet-sidebar.js'],
destDir: 'js'
});
return new TreeMerger([tree, compiledLessTree, sidebarCSSTree, sidebarJSTree]);
},
included() {
this._super.included.apply(this, arguments);
this.import(`vendor/styles/${this.name}.css`);
this.import('vendor/js/leaflet-sidebar.js');
this.import('vendor/styles/leaflet-sidebar.css');
},
isDevelopingAddon() {
return true;
}
});

Jest can't transpile node_modules

I am having the following error when running Jest
SyntaxError: node_modules/my_styleguide/src/components/blocks/SegmentSetting.jsx: Unexpected token (46:10)
44 | ) {
45 | return (
> 46 | <p className="SettingDescr">{self.props.description}</p>
| ^
47 | )
48 | }
49 | }
The node_modules dependency is still in its es6 format. Jest doesn't seem to provide the option to transpile your node_modules, as it does with your actual app. Instead, jest ignores the node_modules folder.
The .bashrc file looks ok to me:
{
"presets": ["es2015", "react", "stage-0"]
}
How do you make Jest transpile your node_modules too? It would be the equivalent of the "--ignore false" flag that we have in mocha.
I would mark this as an answer rather than the answer.
I had a similar issue, multiple components in node_modules in ES2015 and in need of transpilation.
I updated transformIgnorePatterns to:
["/node_modules/(?!(our-react-components-.*?\\.js$))"]
The negative look-ahead for modules in our-react-components-* folders mean Jest (and therefore Babel) will find and transpile our shared components.
This was in an ejected Create React App project with Jest 20.0.4.

Grails: Unable to resolve class groovyx.net.http.HTTPBuilder

I have developped some web services that I would like tu use in my grails application.
These services can be called using Get or POST protocols.
I have seen that I need to use the HTTP builder object to do that.
This is my code:
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.ContentType
import groovyx.net.http.Method
import groovyx.net.http.RESTClient
import groovyx.net.http.HttpResponseDecorator
def http = new HTTPBuilder( 'http://localhost:8086' )
http.request( GET, JSON ) {
uri.path = '/RegistrationService/webresources/users/isRegistered'
uri.query = [ login:'aa', password: 'bb' ]
response.success = { resp, xml ->
def xmlResult = xml
}
}
The problem I have is that in Netbeans I have an error for each import:
Unable to resolve class groovyx.net.http.HTTPBuilder
Unable to resolve class groovyx.net.http.ContentType
...
However I tried to run the application and this is the error when I run my code:
| Error 2013-02-25 23:33:32,596 [http-bio-8080-exec-3] ERROR errors.GrailsExceptionResolver - MissingPropertyException occurred when processing request: [POST] /WordGame/user/authenticate
No such property: uriPath for class: groovyx.net.http.HTTPBuilder$RequestConfigDelegate. Stacktrace follows:
Message: No such property: uriPath for class: groovyx.net.http.HTTPBuilder$RequestConfigDelegate
Line | Method
->> 21 | doCall in wordgame.UserController$_closure2_closure4
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 425 | doRequest in groovyx.net.http.HTTPBuilder
| 359 | request . in ''
| 19 | doCall in wordgame.UserController$_closure2
| 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
I have installed the rest plugin using the command: grails install-plugin rest
And I have already tried to install it with the netbeans interface and it tells me that it is correctly instaled.
I have seen on some forums that I need to had dependencies in the file BuildConfig.groovy like that:
dependencies {
runtime('org.codehaus.groovy.modules.http-builder:http-builder:0.5.1') {
excludes 'xalan'
excludes 'xml-apis'
excludes 'groovy'
}
}
But this is not resolving the problem.
For information I am using netbeans 7.2.1 and Grails 2.2.0.
Is there something wrong with my code or is there a simplier way to request a web service?
Thanks in advance.
so, I read through the Exception you posted and your code snippet again and it seems that you have omitted the req variable within the http.request(){} closure. also you have not imported the GET method and TEXT content type. try:
import groovyx.net.http.HTTPBuilder
//import groovyx.net.http.ContentType // this doesn't import ContentType
//import groovyx.net.http.Method // this doesn't import Method
import groovyx.net.http.RESTClient
import groovyx.net.http.HttpResponseDecorator
// ContentType static import
import static groovyx.net.http.ContentType.*
// Method static import
import static groovyx.net.http.Method.*
def http = new HTTPBuilder( 'http://localhost:8086' )
http.request( GET, JSON ) { req -> // 'req ->' is not present in your code snippet!
uri.path = '/RegistrationService/webresources/users/isRegistered'
uri.query = [ login:'aa', password: 'bb' ]
response.success = { resp, xml ->
def xmlResult = xml
}
}
also I would recommend to read through the documentation of HTTPBuilder at this location: http://groovy.codehaus.org/modules/http-builder/doc/index.html as the code is well explained and some howtos and tutorials are also listed ;)
i just solved my problem.
Download this: http://repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2/
Copy the httpBuilder.jar and all the jars from dependencies directory in your groovy_installed_directory/lib. Then restart console and try again.
Hope it helps.
BR